How to Install Node.js on Ubuntu 26.04

How to Install Node.js on Ubuntu 26.04

This blog post explains how to install Node.js on Ubuntu 26.04. Node.js is a free and open-source JavaScript runtime environment that allows developers to execute JavaScript code outside of a web browser. Before Node.js was developed, JavaScript was client-side-only for adding interactivity to web pages, but after Node.js, it moved to the backend, allowing developers to use a single language for client- and server-side development. Besides this, Node.js is event-driven and non-blocking, handles thousands of concurrent connections, is cross-platform, runs on multiple operating systems, and includes a set of built-in modules.

Installing Node.js on Ubuntu 26.04 is a straightforward process that may take different amounts of time depending on how we use it. Let’s get started!

Prerequisites

Update the System

Before we start installing the LAMP stack, we will update the system packages to their latest versions. Execute the following command:

apt update -y && apt upgrade -y

Installing NodeJS using Ubuntu’s default repository

The fastest way to install NodeJS is by using the default system repository. NodeJS is included in the Ubuntu 26.04 repository, so to install it, simply execute the following command:

apt install nodejs npm

Once installed, you can verify the installation with the command below:

node -v

You should get the following output:

root@host:~# node -v
v22.22.1

Installing NodeJS from NodeSource Repository

In the previous step, we installed NodeJS version 22, but the latest NodeJS version is NodeJS 25. To install a specific version on the system, we use the second way: installation from the Node source, which provides a setup script that configures the repository and automatically installs the required GPG key.

First, we need to install curl for downloading the setup script:

apt install -y curl 

Once installed, we can run the setup script for your desired Node.js major version:

curl -fsSL https://deb.nodesource.com/setup_25.x | sudo bash -

After execution of that, you will receive the following output:

Get:6 https://deb.nodesource.com/node_25.x nodistro/main amd64 Packages [3,035 B]
Fetched 13.6 kB in 0s (46.5 kB/s)
1 package can be upgraded. Run 'apt list --upgradable' to see it.
2026-04-01 00:17:11 - Repository configured successfully.
2026-04-01 00:17:11 - To install Node.js, run: apt install nodejs -y
2026-04-01 00:17:11 - You can use N|solid Runtime as a node.js alternative
2026-04-01 00:17:11 - To install N|solid Runtime, run: apt install nsolid -y

This means that NodeJS 25 was added, and we can install it with the following command:

apt install nodejs -y

The previous version of NodeJS installed via the Ubuntu default repo will be deleted. To check the new installation, execute the command you already know:

node -v

You should get the following output:

root@host:~# node -v
v25.8.2

Installing NodeJS via Node Version Manager (NVM)

Node Version Manager is a command-line tool that allows developers to install, manage, and switch between multiple versions of Node.js on a single machine. This way is preferred when we need multiple versions on our system.

First, we need to install NVM. To do that, download the installation script:

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

Once installed, reload the shell configuration:

source ~/.bashrc

To verify the NVM installation, execute the command below:

nvm --version

You should get the following output:

root@host:~# nvm --version
0.39.7

Now we can list the available Nodejs versions that can be installed with NVM:

nvm ls-remote --lts

The list will be long and will look like this:

         v4.2.0   (LTS: Argon)
v4.2.1 (LTS: Argon)
v4.2.2 (LTS: Argon)
v4.2.3 (LTS: Argon)
v4.2.4 (LTS: Argon)
v4.2.5 (LTS: Argon)
v4.2.6 (LTS: Argon)
v4.3.0 (LTS: Argon)
.
.
.
.
v22.21.0 (LTS: Jod)
v22.21.1 (LTS: Jod)
v22.22.0 (LTS: Jod)
v22.22.1 (LTS: Jod)
v22.22.2 (Latest LTS: Jod)
v24.11.0 (LTS: Krypton)
v24.11.1 (LTS: Krypton)
v24.12.0 (LTS: Krypton)
v24.13.0 (LTS: Krypton)
v24.13.1 (LTS: Krypton)
v24.14.0 (LTS: Krypton)
v24.14.1 (Latest LTS: Krypton)

Now, we can install even NodeJS versions older than 10 years. To install NodeJS 4 version, for example, execute the following command:

nvm install 4.2.2

After installation, you can check the version:

node -v

You should get the following output:

root@host:~# node -v
v4.2.2

To list the installed versions with the NVM, you can use the following command:

nvm ls

Our output was the following:

root@host:~# nvm ls
-> v4.2.2
system
default -> 4.2.2 (-> v4.2.2)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v4.2.2) (default)
stable -> 4.2 (-> v4.2.2) (default)
lts/* -> lts/krypton (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.20.8 (-> N/A)
lts/iron -> v20.20.2 (-> N/A)
lts/jod -> v22.22.2 (-> N/A)
lts/krypton -> v24.14.1 (-> N/A)

Conclusion

In conclusion, installing Node.js via the default Ubuntu repository is the simplest and most stable method, but it often provides outdated versions. Using NodeSource offers a better balance, delivering more up-to-date releases while remaining system-wide and easy to manage. NVM (Node Version Manager) is the most flexible option, allowing multiple Node.js versions and easy switching between them, making it ideal for development environments. The best choice depends on whether you prioritize stability, newer features, or flexibility in version control.

That’s it. You successfully installed NodeJS on Ubuntu 26.04 in three different ways.

Of course, you don’t have to install NodeJS on Ubuntu 26.04 if you have difficulties and you are not familiar with Linux. You can always contact our technical support. You only need to sign up for one of our Node.js hosting plans and submit a support ticket. We are available 24/7 and will take care of your request immediately.

If you liked this post about installing NodeJS on Ubuntu 26.04, please share it with your friends or leave a comment down below.

Leave a Comment