Install NPM in Ubuntu 22.04

NPM is a package manager of Node.js. It was first released in the year 2009. And, at the time of writing, v8.3.2 is its latest stable release. In this article, we would discuss how to install NPM in Ubuntu 22.04 release.

There are two ways to get NPM in Ubuntu –

  1. through standard Ubuntu repository and,
  2. installing Node.js package file.

We will discuss both of the above methods next.

Note: Following operations would require you to have superuser privileges. In case you don’t have one then, we advise you to contact your System Administrator.

Install NPM in Ubuntu 22.04

Method I. Through standard Ubuntu repository –

This one is pretty easy. Just update the repository to make sure we get to have the latest version of package available. Hence, open a terminal and issue the following –

sudo apt update

Thereafter, to install NPM –

sudo apt install npm

To verify for the installed package –

npm -v

It would return with the NPM’s version number.

Method II. Through installing Node.js package file.

The package is available through Node.js Linux Binaries. So, first we have to download Node.js package through its official website. We will discuss the installation of LTS version of Node.js. On the homepage of Node.js website – Download the LTS version. For us it was – node-v16.14.0-linux-x64.tar.xz

Thereafter, we need to extract the package using tar command-line utility.

tar -xvf node-v16.14.0-linux-x64.tar.xz

It will create node-v16.14.0-linux-x64/ in the same directory.

Use cd command-line utility to navigate inside node-v16.14.0-linux-x64/bin/

cd node-v16.14.0-linux-x64/bin/

To verify the version of npm –

./npm -v

In conclusion, we have discussed how to install NPM in Ubuntu 22.04 release.

Additional Info –

In the Method II, we chose to install LTS version. Right on the homepage you would also find current release of NPM. So, if you want the current release. Then, download the Current release package. Thereafter, follow the steps mentioned in Method II. But, package version would be different in this case. So, make changes accordingly.