How to install Node.js on Ubuntu 20.04

I. Introduction

Node.js is a JavaScript runner for server-side programming. It allows developers to create extensible backend functionality using JavaScript, a language many people are familiar with in browser-based web development.

II. Performance conditions

This tutorial simulates that you are using Ubuntu version 20.04. Before you begin, you should have a user account with sudo privileges set up on your system, or if you don’t have one, you can also use the root account.

III. Install Node.js on Ubuntu 20.04

To install Node.js on Ubuntu 20.04 we need to do the following 2 steps.

Step 1: SSH into your Ubuntu 20.04 system

To install Node.js on Ubuntu 20.04, first we need to SSH or access your VPS or server with  root privileges  first. If you do not know how to SSH into your VPS or Server .

After successfully SSHing as root, we continue with step 2 to execute the Node.js installation commands.

Step 2: Commands to install Node.js on Ubuntu 20.04

You should first update your Ubuntu with the following command first.

apt update

After the update is complete, use the following command to install Node.js from the default Ubuntu repositories. At the time of writing, the version in the Ubuntu repositories is Node.js 10.19.

While this is not the latest version of Node.js, it is a stable version with all the features you need.

apt install nodejs 

After running the above command, you will get information about how much space to download and how much space it will take up after installation. You will need to fill in Yto continue the installation process.

how-to-install-cai-dat-nodejs-tren-ubuntu-2004
Run the command to install Node.js on Ubuntu 20.04 .

After the installation is complete, use the following command to check if you have successfully installed or not and if it has been successfully installed, what version has been installed.

  nodejs -v

Below is a log image of my Node.js installation on Ubuntu 20.04 as well as checking the Node.js version I just installed.

how-to-install-cai-dat-nodejs-tren-ubuntu-2004
The installed Node.js version is v10.19.

If the package in the repository suits your needs, this is all you need to do to set up Node.js. In most cases, you’ll also want to install npmthe Node.js package manager as well. You can do this by installing  npmwith the apt command below:

apt install npm

This will allow you to install modules and packages for use with Node.js.

At this point, you have successfully installed Node.js on your Ubuntu 20.04 server.

On this page