How to Install the npm Package Manager for node.js


In this article, we show how to install the npm package manager for node.js.

The npm package manager is the software that installs and manages npm packages or modules installed on your computer.

This may include modules such as the validator module (for string validation), the lodash module, the chalk module, the request module, the commander module, the react module, the express module, the debug module, and the async module.

So the npm package manager is very important for installing and managing npm packages such as those listed above.

To install the npm package manager and then to eventually install packages to use, there are a few steps that need to be done.

First, open up the node.js software that can run terminal commands.

For me, this is Visual Studio Software.

Then go to the terminal on the node.js software and run the following command below:

You should get an output such as the following below.

Initializing npm in node.js

When you initialize npm, a number of things will be asked for, such as the package name, version, description, entry point, test command, git repostiory, keywords, author, and can simple click 'Enter' through all of these without specifying anything. The package will then be installed.

When you initialize npm, you're doing a few things. You're creating a package.json file, which keeps track of all npm modules that you install. You also create a package-lock.json file, which stores meta data about the npm that you have installed such as the version you're using and where it was downloaded from.

So now the npm package manager is installed.

With the npm package manager now installed, you can download npm modules that are very useful to do many programming tasks. For example, with the validator module, we can validate emails with very simple code. Instead of wasting time writing custom code for many tasks, you can just use already built and time-tried code.

Next, we are now free to install npm modules.

In our example, we will be using the validator npm module.

Therefore, you must go to the terminal of your node.js software and type in the following command.


Both do the same thing of installing the validator npm module.

This is how the installation will look.

Installing an npm module in node.js

Once this is installed, you will see a message that the package is added. You will also see that in your node_modules folder, you will see files that pertain to this newly installed npm module, such as validator.js.

And this is how to install the npm package manager for node.js to be able to install and manage npm modules.

Related Resources

How to Find the Version of node.js Installed on Your Computer

HTML Comment Box is loading comments...