Skip to content

Instantly share code, notes, and snippets.

@kenyee

kenyee/gist:6307258

Last active Dec 21, 2015
Embed
What would you like to do?
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
You can’t perform that action at this time.