Node Package Manager

NPMNode Package Manager is three things — a third-party package repository, a way to manage packages installed in  your computer, and a standard to define dependencies on other packages. NPM provides a public registry service that contains all the packages that programmers publish in NPM.

NPM also provides a command-line tool to download, install, and manage these packages. You can also use the standard package descriptor format to specify which third-party modules your module or application depends on.

NPM and Node once required separate installs, but since Node version 0.6.0, NPM is already included.

The Global versus the Local Mode :

NPM has two main modes of operation: global and local. These two modes change target

directories for storing packages. The local mode is the default mode of operation in NPM. This mode is ideal for installing the modules your application depends on without affecting other applications you might also have installed locally.

The global mode is more suited for installing modules that should always be available globally.In the global mode, NPM installs packages into /usr/local/lib/node_modules .Install by using the CLI like:


$ npm install -g express

If you get any error,then you will need to login as the root user or run this command within sudo:


$ sudo npm install -g express

The Local Mode :

The local mode is the default mode of operation in Node Package Manager.In this mode NPM installs everything inside the current directory,which is your application root directory .This way you can choose, application by application, which modules and which versions to include without polluting global module space.

In this mode, NPM works with the node_modules directory under the current working directory. If you are inside /home/dileep/node/first_app , NPM will use /home/dileep/node/first_app/node_modules as file storage for the modules.

This means that, when Node is resolving a module dependency, a module installed using the local mode will always take precedence over a module installed globally.


My Name is Dileep Singh, Noder, Javascript Lover & NoSql Developer, Fitness Freak, Love to travel new places, learning photography & Music Manic ♯ ♩ ♬

Posted in Node.Js Tagged with: