Tutorial Install and config Node.js on Ubuntu 20.04
To let this tutorial work better, please consider the below Prerequisites:
A non-root user with sudo privileges.
To set up, follow our Initial server setup on Ubuntu 20.04.
Install and config Node.js on Ubuntu 20.04 | Ubuntu 18.04
Node.js is free, open-source, and powerful which could be used to create back-end apps. Let’s see the different methods for installing Node.Js and choose the one which is closer to your needs.
Step 1: Install stable Node.Js from Ubuntu repository
First, let’s start with the most recommended way of installing Node.Js on Ubuntu 20.04. Use the command below to install it from the standard Ubuntu repository.
sudo apt install nodejs
When the installation is finished, you check the Node.Js version by running:
node --version v10.15.2
Step 2: Install Node.js with NVM
In this step, you will learn how to install Node.js using Node Version Manager. If you choose the method NVM, you can maintain many different independent versions of Node.js and their associated Node packages at the same time.
sudo apt install curl curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
Once the installation is finished, you need to load the nvm environment in the current shell with the below command:
When NVM installed successfully, you can install the Node.js version with the way of NVM:
nvm install v12.16.2
You can also use the command below for installing multiple Node.js version:
nvm use v12.16.2
Step 3: Install Node.js with PPA
You can use a Personal Package Archive to install a different version of Node.Js. PPA has more versions of Node.Js such as v10,v12, v13, and v14. Run the below commands and remember to replace 12.x with your considered version.
sudo apt install curl curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
After adding the repository, install Node.js by the command below:
sudo apt install nodejs
After complete the installation, run the below command to view the current Node.js version.
Step 4: Install Node.Js from the source
You can use this method to install any version of Node.js. First, you should install the NVM manager:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
Then, use the following command to update your shell environment.
And to check the NVM availability use the command below to check its version.
nvm --version 0.33.8
Then, list all available Node.js version by running:
nvm ls-remote ... v12.13.0 (LTS: Erbium) v12.13.1 (Latest LTS: Erbium) v13.0.0 v13.0.1 v13.1.0 -> v13.2.0
Next, you need to select the Node.js version number you wish to install (take a note if you may forget). Run the following command to install any considered version. For instance:
nvm install 13.2.0
And finally, to check the installed Node.js version, type:
node -v v13.2.0
In this article, you learned How To Install And Config Node.js On Ubuntu 20.04. You have installed the popular Node.Js now and you can install it in various methods due to its version. And also you can manually select your preferred way of installing. In case you are interested in reading more, find our related article on How to Install node.js on Windows.