Skip to content

Instantly share code, notes, and snippets.

@kenyee
Last active December 17, 2022 10:38
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenyee/6307258 to your computer and use it in GitHub Desktop.
Save kenyee/6307258 to your computer and use it in GitHub Desktop.
How to add Node.js npms to your Meteor.js project.
Make a subdirectory named packages/mynpms in your project.
Add a package.js that looks something like this:
Package.describe({
summary: "Custom app NPM dependencies"
});
Npm.depends({
nconf: '0.6.7',
feedparser: '0.16.1'
});
Package.on_use(function (api) {
if (api.export) { // ensure backwards compatibility with Meteor pre-0.6.5
api.export('NCONF');
api.export('FEEDPARSER');
}
console.log('adding nconf/feedparser');
api.add_files("mynpms.js", "server");
});
You also have to add a separate packages/mynpms/mynpms.js file that looks like this:
NCONF = Npm.require('nconf');
FEEDPARSER = Npm.require('feedparser');
Note that these requires cannot be done in the package.js file because this has to be included as a separate runtime .js file (package.js is a management .js that is used before your app is run).
The FEEDPARSER and NCONF variables will then be global variables you can use in your app.
Then in your project root, type in "meteor add mynpms".
NOTE: the last step is *required* for Meteor 0.6.5!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment