What Is Node Package Manager(NPM)?

In this tutorial, i want to explain what is node package manager. 

So let’s start with what is node package manager.

Node package manager is online repositories for node.js packages/modules. To install node package and do version management we have to use commands.

To check current NPM version on your computer type below command

$ npm --version

If you running old version than you can update easily by running below commnand

$ sudo npm install npm -g

How To Install Module Using Npm

Using below command you can install module in node

$ npm install

Suppose you want to install express module of node then you have to type below command.

$ npm install express

Global Vs Local Module Installation

By default npm install local module to use local module you can use require method. To check which module is install locally you use below command

$ npm ls

To install global module you can use below command.

$ npm install  -g

You can use the following command to check all the modules installed globally

$ npm ls -g

Package.Json File

by typing below command you can generate package.json file

$ npm init

If you want to save you locally module in package.json file you can type below command

$ npm install --save express

Above command will save your module name and installed version in package.json file

Uninstall Module

Use the following command to uninstall a Node.js module.

$ npm uninstall express

Updating A Module

Update package.json and change the version of the dependency to be updated and run the following command.

$ npm update express

Search A Module

Search a package name using NPM.

$ npm search express

I hope you like this post, Please feel free to comment below, suggestion and problems!

(Visited 23 times, 1 visits today)
Chandra Kumar

Hello World, I am Chandra Kumar from New Delhi, India. I am professionally developer, programmer and blogger. I am the founder of WebShouters.com.

0 Comment

Leave a Comment

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