Suppose you want to install the current node.js version 20.x on Ubuntu 22.04 system. In that case, you can use 2 simple methods: the first is by using Nodesource, and the second is by using the official repository.
How to Install Node.js 20 on Ubuntu 22.04
Here are 2 simple approaches using which you can easily install the latest Node.js 20.x version in your system:
- Approach 1: Installing Node.js 20.x using Nodesource
- Approach 2: Installing Node.js 20.x using Official Repository
Approach 1: Installing Node.js 20.x using Nodesource
Start your terminal or command line. And start the installation process.
Installing the version of Node JS 20.x requires downloading the repository from nodesource, for this you can use the curl command:
curl -sL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh
To start the installation process of node.js 20.x version, you can use this command:
sudo bash nodesource_setup.sh
Now The PPA package of Node.js 20.x has been added to your Ubuntu system, now you can install the Node.js 20.x version into your system using the command:
$ sudo apt install nodejs
Once installed, to confirm the installation version, use this command:
$ nodejs --version
This will print the current version of node.js on the terminal, it looks like this:
v20.10.0
Approach 2: Installing Node.js 20.x using Official Repository
Let us now look at the second approach. In this we will use the official repository, for this we will take the help of apt package manager commands.
Type the command sudo apt update on the terminal to update all the packages of your system.
sudo apt update
To install node.js 2.0x and latest npm version with the command of apt packager manager, for this, you type the command on the terminal:
sudo apt install nodejs npm -y
When the process is complete on the terminal, if you type the nodejs –version command on the terminal, whatever latest version is installed will show on the terminal:
nodejs--version
This will print the current version of node.js on the terminal, it looks like this:
v20.10.0
Important Note:- By following the first approach, you can effortlessly install a specific version of Node.js on your Ubuntu system.
Here is the video tutorial for installing node.js 20.x on ubuntu 22.04:
Conclusion
With the help of this tutorial, you can install the latest version of Node.js 20.x in your system, for this you have seen 2 simple approaches in this tutorial. You can choose any approach as per your choice and install latest Node JS 20.x version in Ubuntu 22.04.