Node.js is an open-source JavaScript runtime environment. It was developed by Ryan Dahl. Furthermore, it is a cross-platform application built on V8 JavaScript engine of Chrome and written in C, C++ and JavaScript. In this article, we would discuss how to install Node.js in Ubuntu 20.04 LTS release.
Node.js was first released on May 27, 2009. At the time of writing there are three active release of Node.js. These are –
- version – 10.19.0; maintenance support till April 01, 2021
- version – LTS 12.16.2; maintenance support till April 01, 2022
- version – Current 14.0.0; maintenance support till April 01, 2023
There is fourth one too, v13 whose maintenance support is due to end on June 01, 2020. Hence, we have skipped that part.
We would like to clarify here that – version 10.19.0 is available as default in standard Ubuntu repository as we write. Apart from that, if you intend to install the other two versions then it can be done through Linux Binaries available on official website of Node.js.
Note: Following operations would require you to have superuser privileges. In case you don’t know what you are up to, then contact your System Administrator for assistance.
Install Node.js in Ubuntu 20.04 through repository
As already discussed we can install version 10.19.0 through standard Ubuntu repository. For that, we need to update the repository to make the latest version available. So, open a terminal and issue the following –
sudo apt update
Now, to install Node.js –
sudo apt install nodejs
This will install related dependencies (if any) as well. To verify for the version installed, issue the following in terminal –
node -v
or,
nodejs -v
It would return –
v10.19.0
Install Node.js (LTS release) in Ubuntu 20.04 through Linux Binaries
Alternately, we can install LTS release through Linux Binaries available on official website of Node.js. Visit the official website of Node.js and on the Downloads page, click LTS tab & Linux Binaries (x64). It would download the package – node-v12.16.2-linux-x64.tar.xz.
Next, we need to extract the package through tar command-line utility –
tar -xvf node-v12.16.2-linux-x64.tar.xz
This would create a folder node-v12.16.2-linux-x64/ in the current directory.
Now, open ~/.bashrc file using a text editor. We have used nano –
nano ~/.bashrc
and add following entries to it –
export PATH=/path/to/node-v12.16.2-linux-x64/bin:$PATH
where,
/path/to/ should be replaced with the actual path to node-v12.16.2-linux-x64/ directory.
Finally, open a terminal and verify if the package is available or not –
node -v
It should return –
v12.16.2
Install Node.js (Current release) in Ubuntu 20.04 through Linux Binaries
The current version is 14.0.0 which was released on April 21, 2020. It will have all the latest features. To download the Linux Binaries, visit official website of Node.js. On the Downloads page, click Current tab & Linux Binaries (x64). It would download the package – node-v14.0.0-linux-x64.tar.xz.
First, we would extract it through tar command-line utility.
tar -xvf node-v14.0.0-linux-x64.tar.xz
It creates a folder node-v14.0.0-linux-x64/ in the current directory.
Now, open ~/.bashrc with a text editor like nano –
nano ~/.bashrc
and append it with following entries –
export PATH=/path/to/node-v14.0.0-linux-x64/bin:$PATH
where,
/path/to/ should be replaced with the actual path to directory – node-v14.0.0-linux-x64/
To verify for the version installed –
node -v
it would return –
v14.0.0
In conclusion, we have discussed how to install Node.js in Ubuntu 20.04 LTS release. Although NPM – package manager comes as default with Linux Binaries. But, if we have installed Node.js through standard Ubuntu repository. Then, we would have to install it separately which is discussed in next article here – Install NPM in Ubuntu 20.04 LTS.