How to Install Node.Js on Ubuntu 22.04

Node.js is a cross-platform, free, and open-source runtime environment for JavaScript. Fast, scalable, and highly accessible online applications are created using the well-known ‘JavaScript’ programming language. The node.js framework is used to build the backend of web apps and Node Package Manager (NPM) helps to install JavaScript libraries, and node packages on your system.

In this guide, we will demonstrate how you can perform the Node.js installation on Ubuntu 22.04 Jammy Jelly fish distribution using the command line.


  • Ubuntu 22.04 server should be installed on your system.
  • You should have login as a root user or must have root privileges to run administrative commands.

Installation of Nodejs on Ubuntu 22.04

The node.js can install on Ubuntu 22.04 system using the following methods:

  1. Node.js installation using Ubuntu’s official apt repository
  2. Install Node.js using NVM (Node Version Manager)

1. Node.js installation using Ubuntu’s official apt repository

This method is the easiest way for Node.js installation on the Ubuntu system.

First, update apt repositories using this command:

$ sudo apt update

Now, install Node.js on Ubuntu 22.04 using the below-given command:

$ sudo apt install nodejs npm

The above command will install the npm and node.js package manager on your Ubuntu system after confirming the user prompt.

Once installation of the node.js is complete, verify it by displaying the installed node.js version on the terminal window:

$ nodejs --version

As you can see in the above screenshot, the node.js version ‘v12.22.9’ is installed on this system. Similarly, display the installed npm version using this command:

$ npm --version

Test Node.js installation

To test node.js and npm working properly, create a test program in JavaScript. For example, create a file and type the following code:

console.log(“Hello World”);

Save the above file with the ‘.js’ extension. Now run this file using the node.js server. You will see the following output on the terminal:

$ node test.js

2. Install Node.js using NVM on Ubuntu 22.04

Another method to install node.js on Ubuntu 22.04 system is using the NVM. A bash script NVM (Node Version Manager) enables you to manage multiple versions of node.js on your Ubuntu system. If you want to install a specific version of node.js and npm, use the NVM bash script. First, download the nvm script on your system using the below-given command:

$ curl -o- | bash

Close the current terminal window and open it again. Use this command to source the bash file:

$ source ~/.bashrc

To list all  node.js versions  using NVM that are available for installation, use this command:

$ nvm list-remote

If you want to install a specific version of the node.js from the above list, use the below-mentioned command:

$ nvm install v20.3.0

After completing the installation, check the installed npm and node.js versions respectively:

$ node --version

$ npm –version

Uninstall Node.js from Ubuntu 22.04

To uninstall node.js and npm from Ubuntu 22.04 system, use the below-mentioned command:

$ sudo apt purge nodejs npm

The above command will uninstall the npm and node.js packages from your Ubuntu system.


We learned in this guide how to install node.js and npm on Ubuntu 22.04 distribution using the command line. Node.js is a runtime environment that you can easily install on your Linux system using the above steps and can run JavaScript code on the V8 engine. Using npm, you can easily install supportive node packages or modules on your system. Share your feedback via comments in case of any installation issues.

Print Friendly, PDF & Email