Home >> Tutorials >> Node Package Manager (NPM)
Node Package Manager - NPM

NPM is the Package Manager for Node.js packages/modules. NPM is installed by default when you install Node.js

Benefits of NPM:
  1. It Provides and hosts Online repositories for node.js packages/modules which can be easily downloaded and used in our projects. You can find them here: npmjs.com
  2. It Provides the Command-line utility in order to install various Node.js packages, manage Node.js versions and dependencies of the packages.
Check NPM Version
 npm -v
Install Packages/Modules via NPM

Use the following command to install any third party module in your local Node.js project folder

 npm install <package name>

Example: the following command will install Express.js into your node js project inside node_modules folder.

 npm install express
	
 //Or use shorter syntax
 
 npm i express

You can check out express module - npmjs.com

By using --save add dependency into package.json

 npm install express --save
UnInstalling a Packages/Modules via NPM
 npm uninstall express
package.json
{
  "name": "MyNodeProject",
  "version": "1.0.0",
  "description": "My Nodejs Project",
  "main": "app.js",
  "author": {
    "name": "Dev",
    "email": "dev@xyz.com"
  },
  "dependencies": {
    "body-parser": "~1.10.2",
    "express": "~4.11.1",
    "nodemon": "^1.14.12"
  },
  "devDependencies": {
    "grunt": "^0.4.5",
    "grunt-contrib-jshint": "^0.10.0",
    "jshint-stylish": "^0.2.0",
    "time-grunt": "^0.3.2"
  }
}