NPM is a node package manager for the JavaScript programming language.It is the world’s largest software registry. It consistes of a command line client also called NPM and also the default package manager for the javascript runtime environment Node.js. It also have online database of public packages called the NPM registry that hosts thousands of free packages to download and use. Moreover it consists of a command line client that interacts with a remote registry (packages in the registry are in CommonJS format and include a metadata file in JSON format).

Functionalities of NPM (Node Package Manager)

1) Command line utility to install Node.js packages
2) Provide dependency management and version management of Node.js packaged
3) provide online repositories for Node.js packages


The NPM program is installed on your computer when you install Node.js. To install node.js refer:

we can check it is installed or not by

$ which npm
$ npm --version

With Node Package Manager we can install packages in local and global mode. To install packages in local mode we need following command

npm install packagename

In local mode it installs the packages in node_modules folder in parent working directory.This location is owned by the current user.

To install packages in global mode

sudo npm install forever -g

This means you would have to use sudo to install packages globally, which could cause permission errors when resolving third-party dependencies, as well as being a security concern. Global packages are installed in {prefix}/lib/node_modules/ which is owned by root (where {prefix} is usually /usr/ or /usr/local)

To check the npm configuration we need

$ npm config list
; cli configs
user-agent = "npm/3.10.10 node/v6.10.3 linux x64"
; userconfig /home/sitepoint/.npmrc
prefix = "/home/sitepoint/.node_modules_global"
; node bin location = /usr/bin/nodejs
; cwd = /home/sitepoint
; HOME = /home/sitepoint
; "npm config ls -l" to show all defaults

This gives us information about our install. we can also get our current global location by

$ npm config get prefix

This is the prefix, we can also change the value of prefix also by using this command 
For this let first create a new folder in our home directory to save it

$ cd ~ && mkdir .global_node_modules
$ npm config set prefix=$HOME/.global_node_modules

To uninstall the packages we can use

npm uninstall packagename

To fetch the list of installed packages we can use

npm list

There are lot of commands for more info refer:



Leave Comment

Your email address will not be published. Required fields are marked *