Installing modules using npm
The module system in Node is so powerful that consuming a third-party module written by other developers is a piece of cake. Node includes its own package manager called npm
, which is a registry that currently contains over 60,000 unique modules written in Node. These modules are completely open source and available to you via a few short commands. In addition, you can release your own personal modules via npm and allow anyone in the world to use your feature!
Let's say you wanted to include a popular web framework, Express, in your project (the one we will be using later in this book). There are simply two steps required to download a module and use it in your code:
$ npm install express // ** file: usingnpm.js var ...
Get Web Development with MongoDB and NodeJS - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.