NPM stands for node package manager, It is a package manager for node.js applications. It helps you to install, update, remove and publish packages. Node.js package ecosystem is the world's largest ecosystem/repository of open source online libraries.

In Simple terms, you can compare npm to the PlayStore (android). From play store we can get any type of apps which is developed by any android programmer from anywhere in the whole world.

In the same way, we can get any package from NPM developed and published by any nodejs programmer and include it in our nodejs application to reduce the efforts

For example if say Bob wants a calculator in his mobile. he will simply go to the playstore and download it and use it in his android device instead of creating the whole android application.

In the same way if you want to perform say encryption in your node.js application then instead of creating the logic and coding it from scratch you just include the crypto package (which is used for encryption and stuff) from NPM and your task is done.

So npm is basically a package manager for NodeJS, with the help of which we can Find, share, and reuse packages of code from hundreds of thousands of developers — and assemble them in powerful new ways.

Installing NPM

NPM is installed automatically by downloading node.js along with Nodejs, please install nodejs if you have not installed, NodeJS installation steps

NPM Version :

You can verify installed version using below command.

npm -v

You can also check installed node version

node -v

Update NPM :

NPM updates comes more frequently as compared to node.js and it is difficult to download node.js again and again just to update npm. So we have to make sure that we are using the latest version of npm

npm install npm@latest -g

What is package

A package in Node.js contains all the files you need for a module, Similar to your linux installation or like your jar files in Java.

Download a Package :

Open the command line interface and tell NPM to download the package you want.

npm install <package-name>
// Example
npm install nodemailer

NPM creates a folder named "node_modules" in your current directory, where the package will be placed. All packages you install in the future will be placed in this folder.

nstalling specific version of a package :

If you know the exact version of the npm package you want to install, then you can download it using the package_name with @ character. The Syntax is

npm install package_name@version
// Example
npm install nodemailer@2.0.0

Removing a Package :

You can uninstall a package by using uninstall command from the npm

npm uninstall <package-name>
// Example
npm uninstall nodemailer

Install packages Globally :

You can install the packages for the user rather than installing in a specific folder, so that you can access the packages from anywhere in the system

npm install <package-name> -g   or npm install -g <package-name>
// Example
npm install nodemailer -g

UnInstall packages Globally :

uninstall the global packages

npm uninstall <package-name> -g or npm -g uninstall <package-name>
// Example
npm uninstall nodemailer

What is package.json

This file can contain a lot of meta-data about your project. But mostly it will be used for two things:

  • Managing dependencies of your project and installing not available packages
  • Scripts, that helps in generating builds, running tests and other stuff in regard to your project

Please do visit out dedicated section of Package.json

Creating a package.json file :

Run the command npm init and it will ask you some information about your project and will create a basic package.json in that directory.

You need to provide some basic details and your package.json will be ready

  "name": "npm-example",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  "author": "",
  "license": "ISC"

Install with Package.json :

If we are having a package.json file in our project, then we can install all our dependencies using just npm install command rather than installing one by one.

npm install

About Author

Myself KarthiQ, I am the author of this blog, I know ways to write a good article but some how I donot have the skills to make it to reach people, would you like help me to reach more people By sharing this Article in the social media.

Share this Article Facebook
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions

Recent Addition

new tutorial Selenium Online Training : Our next online training course for Selenium with Java starts from 17th December 2018.

You can attend first 3 classes for free, the total course fee is INR 10,000

The course time would be 8.00 PM(IST) for the first three classes

If you are interested to learn, then you can join the course by sending email to

or Register below

Join My Facebook Group
Join Group