It’s simple to node.js install on Ubuntu, and it’s a strong tool for creating server-side apps. Node.js can be installed on Ubuntu using a variety of techniques. Each of these has benefits and drawbacks. With node.js also you can understand how to Install ElasticSearch on Ubuntu Itself.

Using the Ubuntu package manager to install Node.js is the simplest. The most recommended approach. This method entails downloading the most recent versions of Node.js. Also npm from the Ubuntu repository. Installing them using the apt package manager. The majority of consumers are advised to choose this technique. Just because it is simple to use and offers a secure installation.

You may install and switch between various Node.js versions using nvm (Node Version Manager). If you need to handle many Node.js versions on your PC. Installing nvm, a utility that enables simple management of several Node.js versions. It is necessary for this procedure. You can download and install certain Node.js versions as needed. Then switch between them using nvm.

Different Techniques of Installing Node.js on Ubuntu

Option 1: Download and Install Node.js from the Official Ubuntu 22.04 23.04 Repository

Npm and Node.js are included in the standard Ubuntu repositories. As a result, installing them is simple using the APT package manager. Update the Ubuntu system first:

$ sudo apt update

Next, use apt to install Node.js and NPM as seen below:

$ sudo apt install nodejs npm

With this, Node.js and other necessary components are installed.

Option 2: Install Node.js from Nodesource as an Alternative.

To assist businesses in running production-ready Node.JS applications with performance, reliability, and security in mind, Nodesource is a Node.JS partner. If you want to install more recent versions of Node.JS and NPM, use this technique.

The installation script that NodeSource offers refreshes the repository and adds the Nodesource repository to the list of sources. Therefore, download the script and execute it as follows using the curl command:

$ curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -

Install Node.JS using these instructions after the script has successfully run.

$ sudo apt install nodejs

This sets up Node.js along with other required dependencies and libraries. Run: to verify Node.js is installed.

$ node --version

install node js on ubuntu 23.04

Option 3: Set up NVM to Install Node JS and NPM

The script known as NVM, or “Node Version Manager,” enables you to control multiple Node.js versions on your computer. Run the following script to download and install NVM before installing NodeJS and NPM with it:

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

On the terminal, you will see a number of outputs as depicted.

setup nvm script for installing node js and npm

Then, execute the instructions listed below to load nvm:

$ export NVM_DIR="$HOME/.nvm"
$ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
$ [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

Check the installed version of nvm as follows:

$ nvm -v

check installed nvm version

Run the following command to get a list of every Node.js version that supports NVM:

$ nvm ls-remote

check available node js versions using nvm command

Next, you can install the latest available version of node.js with the following command:

$ nvm install node

Enter the version number to install a certain Node.js version. Run the following command, for example, to install NodeJS 18.1.0:

$ nvm install 18.1.0

Final Thought of Installing Latest Version of Node.js on Ubuntu

There are various ways to install Node.js on Ubuntu 22.04, 23.04, 20.04 each having pros and cons of their own. The approach you select will be determined by the needs and conditions you have. The most straightforward and suggested approach for managing. Managing various versions of Node.js is the Ubuntu package manager. Although more experienced users might prefer to utilize NodeSource or NVM.

In the end, the strategy you use will rely on your unique wants and demands. The Ubuntu package manager technique is the simplest and best choice. Especially if you’re just getting started with Node.js. The NVM or NodeSource methods may be more appropriate if you have more complex requirements.

Hope you got a crystal clear view of installing node.js. Such as requiring a certain version of Node.js or managing several versions of Node.js. A pre-built package can be the best choice if you’re utilizing a certain platform. A framework that needs a customized version of Node.js.