In this write-up, we are going to explore the installation methods for the Node.js in Ubuntu 22.04 as well as discuss the basic usage of the Node.js on Ubuntu 22.04.
There are three majorly used methods to install the Node Js on Ubuntu 22.04 which are:
All these methods are explained in detail in the following sections.
Like previous releases of the Ubuntu 22.04, the installation medium of the Node.js are included in the default repository of the Ubuntu 22.04 using the apt package manager:
To confirm the installation of the Node.js, we will check its version:
The above output shows that the Node.js has been successfully installed on Ubuntu 22.04. You might encounter a dependency error while installing the Node.js using the package from its default repository like:
This can be resolve by fixing the broken packages:
PPA repository includes the software repositories of different packages which are specially designed for the Ubuntu users. We will first add the PPA repository of the latest release of the Node.js:
After adding the PPA repository of the Node.js, we will install it using the apt package manager:
Again will confirm the installation of the Node.js by displaying its version:
The NVM (Node Version Manager) is also used for installing the Node.js, the good thing about the NVM is that displays the list of all available versions of the Node.js, from which you can either install the latest version or any particular version of the Node.js. To download the NVM, use:
Now we will run the following commands:
When the above-mentioned commands are successfully executed, we will check the version of the installed NVM:
Display the list of all versions of the Node.js which are available on NVM:
You can either install any of the Node.js versions available in the above list or can install the latest version using the command:
We will validate the installation by displaying the installed version of Node.js:
Javascript is known as a programming language which has popular use in web development and it is easy to learn. We have learned in the above sections about the installation of Node.js whereas here we will simply learn the usage of a node in executing the Javascript file. We will first create a text file using the nano text editor:
Now we will type the code for the simple addition of the two numbers by using the Javascript:
In the above code, we simply assign two values in variable a and b, and add them together to display the output. To run the output of the above code, we will use the command:
The output of the sum of both numbers has been displayed.
If there is no need for the Node.js, we can remove it from the Ubuntu 22.04 in order to free up the space for new packages by using the command:
Javascript is a well-known programming language used in the development of websites and for Javascript code, we have to use Node.js. In this write-up, we have installed the package of Node.js in three different ways and also learn the usage of Node.js on Ubuntu 22.04 by running a simple code of Javascript.
Canonical Livepatch is a security patching automation tool which supports reboot-less security updates for the…
Apache Spark has always been very well known for distributing computation among multiple nodes using…
Data centers are popping up everywhere. With the rapid growth of AI, cloud services, streaming…
Our commitment to building a thriving open source community is stronger than ever. We believe…
The clock was ticking: Node.js 18’s upstream End of Life (EOL) The OpenJS Foundation is…
June 25th, 2025 – Canonical, the company behind Ubuntu, and Pure Storage, the IT pioneer…