How to Install NPM in Ubuntu 22.04?

Npm is the JavaScripts programming language package manager and the default manager for node.js. It is open source, so developers worldwide share codes on this platform. The NPM contains three major parts that are, i.e. website, command line interface, and registry.

This post will address the possible installation method of NPN on Ubuntu 22.04 with the following outcomes:

How to Install NPM in Ubuntu 22.04?

NPM is available on the official repository of Ubuntu 22.04 and can be installed using the following steps:

Step 1: Update the packages

First of all, update all the packages of Ubuntu using the command:

$ sudo apt update

Step 2: Find the Package of NPM

Then the availability of NPM package in Ubuntu has been checked in the default repository of Ubuntu by running the command:

$ apt show npm

Step 3: Install the NPM Package

8.5.1 version of NPM is available in the repository of Ubuntu which can be installed by running the command:

$ sudo apt install npm -y

After the installation, display the version of installed NPM in Ubuntu using the command:

$ npm –version

To find out more about NPM usage, execute the command:

$ npm --help

How to Uninstall NPM on Ubuntu 22.04?

And if it is supposed to remove the package of NPM from Ubuntu, then run the command:

$ sudo apt purge npm -y

The package of NPM will be removed after the successful execution of the above command.

Alternate Installation Method

NPM can be installed by adding the NodeJS repository from the official website and installing it on the system. The steps followed are provided below:

Step 1: Add the NodeJS’s Repository

First, download the script using the command (the script is obtained from the official website of NodeJS):

$ curl -fsSL | sudo -E bash -

Step 2: Install NPM Through NodeJS

Now, use the command provided below to install NPM on Ubuntu 22.04 by installing NodeJS. The NPM package will be installed alongside NodeJS:

$ sudo apt install nodejs

Verify the version via the command;

$ npm -v

It is concluded that the NPM’s latest version has been installed using this method.

That’s all from this guide.


For the installation of the NPM, the easiest method is to install it by running the command “sudo apt install npm -y” in the terminal. It can also be installed by adding the NodeJS repository from the official website. This post has briefly explained the installation methods of NPM on Ubuntu 22.04.