NodeJs – NPM

What is NPM ?

NPM refers to node package manager . It means a node packages or node modules you like to use.

NPM is an command line tool so that you can install,update and uninstall NodeJs packages from your application. You can download and install 1000’s of free packages from .

NPM is included by default with nodeJs installation.To verify the NPM installation run the following command in your command prompt .

npm -v 

If you are using an older version of nodeJs and you can update it with following commands.

npm install npm -g

If you want to access the npm help ,write npm help in the command prompt or terminal window.

npm help

Install package Locally :

Using the following commands to install your third party module into your Local nodejs folder .

The module is accessible inside the node project folder only.Once you install the package it will be added under the node modules folder containing all NPM installed module in it.

D:\node project> npm install express

Install Package Globally :

NPM can also install the package globally so that the nodejs application can use the installed packages all over the system.Installing the package globally can be done easily with the following codes.

D:\node project> npm install -g express

Applying -g in the installing command makes the module global.

Add dependency into package.json :

Package.json is a plain JSON text file that contains all the meta data information about the nodejs project. For example: name of the project,author of the project ,no of installed packages etc., If you are moving the project to somewhere else you dont need to re-install package again.just NPM install i to re-install all the packages using package.json .

NPM init – to initiate a package.json file.

  "name": "NodejsApp",
  "version": "0.0.0",
  "description": "NodejsApp",
  "main": "app.js",
  "author": {
    "name": "Techiesbook",
    "email": ""
  "dependencies": {
    "express": "^4.13.3"

Uninstall a package :

Use the following command to remove the installed packages from your Node modules.

D:\node project> npm uninstall express

Next chapter >> Events

Leave a Reply

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