In this article, we’ll guide you on how to install node.js on Ubuntu 20.04 LTS. To install node.js we need to add Node.js PPA (Personal Package Archive) to our Ubuntu 20.04 LTS, 18.04 LTS, and 16.04 LTS systems. The latest version of Node.js PPA is maintained by its official website on GitHub. Node.js is one of the most popular web technologies that help us build scalable network applications quickly.
What is Node.js
Node.js is an open-source, cross-platform, back-end JavaScript runtime environment. Many developers use Node.js to increase the functionality of a web application. The primary benefit is that Node.js executes JavaScript code outside a web browser. Node.js was designed to build scalable network applications.
You can apply the exact instructions for any Debian-based distribution, including Kubuntu, Lubuntu, Xubuntu, Linux Mint, Pop!_OS, and Elementary OS.
Install Node.js on Ubuntu 20.04 with PPA
There are different ways to install Node.js. However, we will show you the two most efficient and easiest ways to install Node.js. Also, you can download the Node.js latest version via .rpm, .deb, and Snap packages.
1. Add Node.js from NodeSource
This is the easiest method to install a specific version of Node.js. You can quickly follow the steps below to install Node.js 18.x, 17.x, 16.x version. To install Node.js and npm from the NodeSource repository, follow the below steps:
Current Release:
Currently, Node.js v18.4 is the latest release available. First, let’s add the latest Node.js PPA to our system to install Nodejs on Ubuntu.
curl -sL https://deb.nodesource.com/setup_current.x | sudo -E bash -
LTS Release (Recommended):
Currently, Node.js v16.x is the stable LTS release available.
You should always use the versions marked LTS that says “Recommended for Most Users” on the download page which is Node.js version is 16.15.1. First, let’s add the latest Node.js PPA to our system to install Nodejs on Ubuntu.
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
If you want to install another previous version of Node.js then change the version number. For example 17.x, 15.x etc.
2. Install Node.js on Ubuntu 20.04
Once the Node.js PPA is enabled, install Node.js using apt install
command. It will also install NPM with Node.js. Also, it will install many other dependencies on your systems.
sudo apt install npm
sudo apt install -y nodejs
3. Check Installed Node.js and NPM version
After, Node.js and NPM are successfully installed in our system. We can check and verify the installed Node.js version using the following command.
node --version
Output:
16.15.1
Now let’s check npm version by typing the following command.
node --version
Output:
6.13.6
Uninstall Node.js on Ubuntu 20.04
If you want to remove Node.js and npm packages from your systems, use the command below:
sudo apt-get purge nodejs npm
Now use autoremove
command to remove any unused files and packages to free up disk space.
sudo apt-get autoremove
We hope you have found this article helpful. Let us know if you have any questions or feedback through the comment section below.