npm Commands and Features You Should Know

Reading Time: 4 minutes

In this blog we will see how to install npm, and master common commands in the Node Package Manager (npm) features and command-line interface. So, let’s start!

Node Package Manager:

npm or the Node Package Manager, is one of the most used tools for any Node.js developer.npm is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency conflicts intelligently. It installs the packages you want to use and provides a useful interface to work with them. 

Here’s a list of the most common commands you’ll use when working with npm:

Installing npm

npm is installed with Node.js. So, you don’t have to install it separately. You can install node.js from their official website After installing node, You can check the version of node and npm by


The package.json is the project manifest file. Using package.json you can manage dependencies and write scripts. It has all the metadata about the project.

For creating package.json firstly, move to your project folder and run this command:

It asks you for some data like author name, description etc. You can just press enter for defaults.

Install npm Updates

If you realize you have an older version, you can update as follows:

Installing packages:

  1. Locally: A locally installed package can be accessed only on the folder you’ve downloaded it. To perform a local install all you have to do is:

I have used here the flag –save so the package name and version is saved into your package.json file.

  1. Globally: You can also install packages globally, which means Node.js will be able to access them from any project you might need. To install global packages you’ve to use the -g flag.

Updating packages:

Since we have installed packages sometimes we need to update our packages to get new features. For updating particular package run this:

Or run this to update all packages:

And for updating global packages, you’ve to use -g flag:

Uninstalling packages:

Let’s assume that my current package is causing us compatibility problems. So, We can remove the package and install an older version:

For global packages,

List of installed packages:

This will list all the packages including its dependencies of all packages. Run this command:

Outdated Command:

Check the registry if any specified package is outdated. It prints a list of all packages which are outdated.

Start Command 

Runs a command that is defined in the start property in the scripts. If not defined it will run the node server.js command.

Build Command

It is used to build a package.

Search Command

Searches the npm registry for packages matching the search terms.

Owner Command

Manages ownership of published packages. It is used to manage package owners. You can list it by:

We can add owner by:

You can also remove owner by:

Doctor Command

Checks our environment so that our npm installation has what it needs to manage our JavaScript packages.

Help Command

Searches npm help documentation for a specific topic. It is used whenever the user needs help to get some reference.


This has been an overview of the npm commands and features that I find most useful. Now you’ve learned all the basics of npm.You can start using it in your own projects. Thanks for being with me till the end. If you find this blog helpful do share with your friends.


Written by 

Naincy Kumari is a DevOps Consultant at Knoldus Inc. She is always ready to learn new technologies and tools. She loves painting and dancing.