Node.js NPM – Using Node Package Manager

  • by

What is NPM?

NPM stands for Node Package Manager. It is world’s largest online open-source javascript projects repository. Large number of libraries are added everyday on NPM by developers and they are all available at . NPM gets installed when you are installing Node.js. It provides a command-line utility to install a package. In Visual studio code, we can access npm by opening terminal window. You can open a new terminal window by pressing Ctrl + Shift +` keys together. To check npm version installed on your system type command npm -v


Downloading and Installing a package using NPM:

To download and install a package using NPM simply use:

npm install package-name

Example: We will install nodemon in our project. nodemon is a library which helps in automatically restarting the node application when a file change (inside a project) is detected. We will learn more on nodemon in this tutorial series later on.

Install nodemon using npm:

npm install nodemon


Whenever a package is installed using npm, package details are added in project’s package.json file. You can open and view it. It will contain package name and version details. Also npm creates a folder with package name inside node_modules folder.

To update a package using npm use command: npm update packagename

Example: npm update nodemon

This command will update nodemon package to its latest version.

To uninstall a package using npm use command: npm uninstall packagename

Example: npm uninstall nodemon

In the next section we will learn about http package and how to use it in our Node.js project to call and pass data Web-APIs.