Node Package Manager (npm) comes bundled with Node. It allows you do search Node repositories for packages and modules. Anything that is searchable on search.nodejs.org is also searchable by npm. npm can be used to install Node packages on your system. It also performs version and dependency management for all Node packages installing on your system. To find out the version of npm you are using, simply type the following command

$ npm --version
3.10.6

To upgrade you npm,

$ sudo npm install npm -g
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
npm@3.10.6 /usr/local/lib/node_modules/npm
$ npm --version
3.10.6

To install a module

$ npm install express

where express is a module. Express.js is now installed in the local Node repository. To use it, you will need to require it as follows:

var ex = require(‘express’);

To list all installed modules

$ npm ls

To uninstall a module

$ npm uninstall express

By default all modules are installed locally. They are only visible in the directory and subdirectories or the directory you were in when you ran npm install. To make the a module visible globally (to all applications in your system), you need to install it globally as follows:

$ sudo npm install express -g

This will install the module to /usr/local/lib or some other global location. To view globally installed modules

$ npm ls -g

To update a module

$ npm update express