Node Package Manager (NPM) has thousands of modules available. Knowing how to add an npm module for use in your Meteor project gives you access to all of those modules. This recipe will show you how to do this.
You will need to make sure that you have Meteor and Node/npm installed.
You will also need a project that makes use of a custom-built package. We will be using the project from the Building a custom package recipe, found in this chapter.
We first need to add a reference to the npm package that we would like to add, which in this case is going to be the colors
module.
Inside your custom package (the one in the
packages/
subfolder of your app), in thepackage.js
file, add anNpm.depends
statement to the end of the file, as shown in the following example:Npm.depends({ "colors": "0.6.2" });
Now we need to add an
Npm.require
reference to thecolors
module and change ourconsole.log()
command to use a rainbow of fruit flavors. Change yourserver...