If you are like me, you bashed your head against the wall the first time you tried to add an npm module to a Meteor installation. I changed into my Meteor directory and did a standard
npm install module_name; this of course seemed to go fine, then when I launched Meteor, it crashed out with nasty errors about the module not being declared or something. So I added the require to my .js but still no dice.
There are a small number of ways around this. Firstly you can do the require in a slightly different way, consider:
var foo = __meteor_bootstrap__.require('foo');
Alternatively, the cleaner:
var bar = Npm.require('bar');
These are ok, but still make my otherwise clean code look a little clunky.
The cleanest way I found to do this was actually to install the module directly in the Meteor application server space, thusly:
$ cd .meteor/local/build/server $ npm install module_name
Voila! No special code necessary, just the regular
require(), and your module is neatly tucked away with the rest of your Meteor server.