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
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:
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.
Now let’s check npm version by typing the following command.
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
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.