Book Image

Meteor Cookbook

By : Isaac Strack
Book Image

Meteor Cookbook

By: Isaac Strack

Overview of this book

Table of Contents (19 chapters)
Meteor Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using npm modules


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.

Getting ready

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.

How to do it…

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.

  1. Inside your custom package (the one in the packages/ subfolder of your app), in the package.js file, add an Npm.depends statement to the end of the file, as shown in the following example:

    Npm.depends({
        "colors": "0.6.2"
    });
  2. Now we need to add an Npm.require reference to the colors module and change our console.log() command to use a rainbow of fruit flavors. Change your server...