Install NPM in Ubuntu 20.04 LTS

In this article, we would discuss how to install NPM in Ubuntu 20.04 LTS release. NPM is a package manager Node.js. It is written in JavaScript. This article should be considered as an extension to the article – Install Node.js in Ubuntu 20.04 LTS.

Unlike in Node.js package, where we get to install three different versions of Node.js. In case of NPM, it is just one version – 6.14.4. So, whether we install NPM through standard Ubuntu repository or LTS/Current release from Linux Binaries. It wouldn’t make any difference.

Although, we would like to clarify – NPM isn’t installed as default when we install Node.js package through standard Ubuntu repository. However, NPM comes bundled with the Linux Binaries of Node.js. So, in that case no separate installation is needed. But, we will discuss that part in the article as well.

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

Install NPM in Ubuntu 20.04 LTS through repository

Since the package is already available in standard Ubuntu repository. Therefore, first we need to update the repository to make the latest version of the package available. Hence, open a terminal and issue the following –

sudo apt update

Next, to install NPM –

sudo apt install npm

To verify the version of NPM we have installed –

npm -v

It would return –

6.14.4

Install NPM in Ubuntu 20.04 LTS through Linux Binaries

Alternately, the package comes bundled with Node.js Linux Binaries. Therefore, all we need to do is install Node.js Linux Binaries.

Download the Linux Binaries from the official website of Node.js. On the Downloads page –> Click Current/LTS release of Node.js Linux Binaries (x64).

For Current release package – node-v14.0.0-linux-x64.tar.xz.

Now, we need to extract the package through tar command-line utility –

tar -xvf node-v14.0.0-linux-x64.tar.xz

This will create node-v14.0.0-linux-x64/ in the current directory.

Now, open ~/.bashrc using a text-editor. We have used nano

nano ~/.bashrc

and, append it with the following –

export PATH=/path/to/node-v14.0.0-linux-x64/bin:$PATH

where,

We should replace /path/to/ with appropriate entries.

Lastly, open a terminal and issue the following –

npm -v

It should return –

6.14.4

Similarly, for LTS release – node-v12.16.2-linux-x64.tar.xz

Extract the package using tar command-line utility –

tar -xvf node-v12.16.2-linux-x64.tar.xz

This creates a directory – node-v12.16.2-linux-x64/

Using a text-editor like nano, open ~/.bashrc

nano ~/.bashrc

and append it with the following –

export PATH=/path/to/node-v12.16.2-linux-x64/bin:$PATH

where,

/path/to/ is to be replaced.

Lastly, open a terminal and issue the following –

npm -v

It should return –

6.14.4

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

Similar Posts