Introduction

NPM is a Node.js package manager. It provides a bunch of open-source packages.

To use these packages we need NPM CLI. It is a node.js built-in command interface. It allows us to install and interact with packages for our node.js/javascript projects. Most developers understand NPM as an installation pathway.NPM is entirely written in Javascript. It is the cornerstone for modern web app development for any developer entirely using node.js.

INSTALL NPM

  • Visit the page nodejs.org and download the package installer.
  • Run the installer downloaded in the step above.
  • Follow the instructions given in the installer, like accepting the license agreement, clicking on “next”, and accepting the default installation.
  • Restart the computer to run NPM successfully.


How To Check the NPM Version?

Note: Ensure Node is installed in your system before running this command; otherwise, it’ll not show any result.

Follow the steps mentioned below to check the NPM version of the system.

Step 1: Open “Run” on a computer or laptop and use the shortcut “window + R” rather than hitting the search for run and save time.

Step 2: Enter “cmd” to open the command prompt.

Step 3: Now to check the NPM version, type the command

NPM--version or NPM--v

Updating NPM

NPM is a different package from node.js. It is updated regularly. Once installed we need to update to a newer version regularly. Updating NPM means we are updating the package manager, node.js, and the modules to the latest version.

We can update NPM through different commands:

Ø Using Update Command: we can use the npm update command for updating the node package manager.

npm update -g

Ø Using npm@latest command: we can use npm@latest command for updating the node package manager. This command will also work for the Linux system.

npm install npm@latest -g

Ø Using npm@next command: we can use npm@next command for updating the node package manager. This command will also work for the Linux system.

Npm install -g npm@next

Updating NODE

To update node.js we need to ensure that our system has already installed node.js. If not then install it first.

To update node.js we can use node@version command.

SYNTAX: npm install -g node@<version>

As node latest version is Node v16.9.0 we can use command

npm install -g node@v16.9.0.

And our node will be updated to its current version.

Conclusion

Node.js has become popular fro creating interactive websites and web-based applications. It comes with npm (Node Package Manager)that helps manage the packages, modules, and dependenciesof Node.js. We must use the latest stable NPM version for our products to experience the latest functionalities.