How To Install Node.js on Ubuntu 20.04

Windows Articles

How to update apps on Android

Hi folks! In this post, we will show you how to update your Android apps. Updating the apps on your device is...

How to install Apache Ant on Ubuntu 20.04?

Hello, friends. Apache Ant is a very important tool for the development of applications in Java. So in this post, we will...

How to use the ss command

For Linux users, there will come a time when you need to know about the network. Several tools help in this process,...

How to create user template in Windows Server 2019/2016

Hello! Windows Server has many features that support system administration. For example, through the users it is possible to manage many administrative...

Debian 10.6 available

Several volunteers have developed the free software distributed under the name of Debian. Debian does not sell its software directly, the developers...

Today we are going to learn how to install Node.js on Ubuntu 20.04. Node.js is an open-source cross-platform used for developing web applications, network tools, and other such applications. Node.js comes with two versions. One is long term support and the other is the latest version. Just follow the below steps for the easy and optimal installation of Node.js on Ubuntu 20.04.

Step 1: Update your Ubuntu System

To install any package on our system, first update it to the latest packages. Run the below command in your terminal.

sudo apt -y update

Step 2: Installing Node.js on Ubuntu 20.04

Node.js can be installed on our Ubuntu 20.04 system using different methods. Here I listed the three methods to install Node.js on our Ubuntu system.

  • By Node Source Repository
  • With the help of NVM (I recommend to install using NVM)
  • By Ubuntu Repository

You can select your desired option but I recommend to install Node.js using the NVM second method listed above. Here we’ll see all the methods.

Step 3: Install Node.js with Node Source

To install Node.js with the help of Node Source, add the node source repository by firing the below command in your terminal.

Node.js 12 (LTS)

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -

Node.js 14 (Current Version)

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

After adding the repository simply hit the below command to install the Node.js. There will be also an additional package installed on your system called NPM. NPM is the Node Package Manager used for the purpose of Java language.

sudo apt -y install nodejs

Verify the version of installed Node.js by running the below command.

node -v

Output:

You’ll see the similar results

sabir@Ubuntu20:~$ node -v
v12.18.0

Also, you can find the NPM version by typing the given command in your terminal.

npm -v

Output:

sabir@Ubuntu20:~$ npm -v
6.14.4

Step 4: Installing Node.js by NVM

NVM stands for Node Version Manager helps us to switch between the different versions of Node.js. So, you can install the desired one with the help of NVM. To install Node.js using NVM, first install the NVM by typing the below command.

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

Now, close the terminal and then open it again to make sure that nvm is loaded.

Then install the Node.js with the help of below command.

Node.js 12 (LTS)

nvm install --lts

Node.js 14

nvm install node

Verify the version by

sabir@Ubuntu20:~$ node -v
v14.4.0
sabir@Ubuntu20:~$ npm -v
6.14.5
sabir@Ubuntu20:~$

Some NVM Commands

You can list the available versions of Node.js with the help of below command.

nvm ls-remote

For installing the specific version just type the name of the version in front of the nvm install command like below.

nvm install 12.18.0

To get list of all installed versions of Node.js on our system hit

nvm ls

Output:

sabir@Ubuntu20:~$ nvm ls
v12.18.0
-> v14.4.0
system
default -> lts/* (-> v12.18.0)
node -> stable (-> v14.4.0) (default)
stable -> 14.4 (-> v14.4.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/erbium (-> v12.18.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.21.0 (-> N/A)
lts/erbium -> v12.18.0

If you want to use different version from installed hit

nvm use 14.4.0

For removing any version hit

nvm uninstall 12.18.0

Step 5: Install Node.js by Ubuntu Repository

As this is available on Ubuntu repository, so its fast and easy to install hit the below command.

sudo apt update
sudo apt install -y nodejs

Verify the version by

node -v

So, this is how you can install Node.js on Ubuntu 20.04 using different methods.

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How to update apps on Android

Hi folks! In this post, we will show you how to update your Android apps. Updating the apps on your device is...

How to install Apache Ant on Ubuntu 20.04?

Hello, friends. Apache Ant is a very important tool for the development of applications in Java. So in this post, we will...

How to use the ss command

For Linux users, there will come a time when you need to know about the network. Several tools help in this process,...

How to create user template in Windows Server 2019/2016

Hello! Windows Server has many features that support system administration. For example, through the users it is possible to manage many administrative...

Debian 10.6 available

Several volunteers have developed the free software distributed under the name of Debian. Debian does not sell its software directly, the developers...