Last active
December 17, 2022 10:38
-
-
Save kenyee/6307258 to your computer and use it in GitHub Desktop.
How to add Node.js npms to your Meteor.js project.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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