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’s Kubernetes LTS (Long Term Support) will support FedRAMP compliance and receive at least 12…
Welcome to the Ubuntu Weekly Newsletter, Issue 878 for the week of February 2 –…
At Canonical, we firmly believe that delivering an outstanding, customer-centric support experience is impossible without…
I want to share how to install osTicket v1.14 for Ubuntu 20.04 server. osTicket written…
Now I want to share how to install WordPress on ubuntu 20.04 server. WordPress is…
Now I want to share the DNS server installation process on your Ubuntu 20.04 server.…