How To Install Node.js on Ubuntu 26.04 LTS

Install Node.js on Ubuntu 26.04

If you want to install Node.js on Ubuntu 26.04 LTS, the process is straightforward but the wrong method will cost you hours of debugging later. Ubuntu 26.04 “Resolute Raccoon” ships with Node.js 22 in its default repositories, but that package comes with npm 9.2.0, which is two major versions behind the current npm 11.x line and incompatible with several modern lock file formats.

This guide walks you through four tested installation methods: the Ubuntu APT repository, NodeSource PPA, NVM (Node Version Manager), and fnm (Fast Node Manager). You will learn not just which commands to run, but why each step exists, so you can troubleshoot problems independently and make the right call for your specific environment.

By the end of this tutorial, you will have Node.js installed, npm verified, and a working HTTP server running on Ubuntu 26.04 LTS. Whether you are setting up a production server or a local development environment, there is a method here that fits.

Prerequisites

Before you start, confirm you have the following in place:

  • Ubuntu 26.04 LTS installed (fresh server or VPS instance preferred)
  • A non-root user with sudo privileges configured
  • SSH access or direct terminal access to the machine
  • curl available (sudo apt install -y curl if missing)
  • ca-certificates and gnupg for methods involving external repositories
  • A stable internet connection for downloading packages
  • Basic familiarity with the Linux command line (you should know what cd, ls, and sudo do)

If you are working on a cloud VPS, make sure your firewall rules allow outbound HTTPS (port 443) so package scripts can reach external servers.

Which Installation Method Is Right for You?

Not all four methods work equally well for every situation. Here is a quick breakdown to help you decide before you type a single command.

Method Node Version npm Version Multi-version Support Best For
Ubuntu APT 22.22.1 9.2.0 No Quick installs, CI/CD runners
NodeSource PPA 24.x / 22.x 10.9.7+ No Production servers
NVM 24.14.1 / 25.9.0 11.11.0+ Yes Development, multi-project setups
fnm 24.14.1 / 25.9.0 11.11.0+ Yes Fast dev environments

The key difference between these methods is the npm version gap. Ubuntu’s APT ships npm 9.2.0, while NodeSource delivers npm 10.9.7 and NVM/fnm bring npm 11.x. If your project uses package-lock.json v3 format or npm workspaces, you need at minimum npm 7. For anything in active development, aim for npm 10 or higher.

Step 1: Update Your System Package Index

Before installing anything, refresh your local package metadata.

sudo apt update

WHY this matters: Ubuntu’s package index is essentially a catalog of available software versions. When the catalog is stale, apt install either pulls outdated packages or fails to resolve new dependencies entirely. On a fresh Ubuntu 26.04 install, the default metadata can be several days old.

Note that apt update does NOT upgrade your installed software. It only synchronizes the package list. You will see output like this:

Hit:1 http://archive.ubuntu.com/ubuntu noble InRelease
Reading package lists... Done
Building dependency tree... Done

This step takes about five to thirty seconds depending on your connection speed. Do not skip it.

Step 2: Install Node.js from the Ubuntu APT Repository

This is the fastest method and the right choice when you need a quick system-wide install on a CI/CD runner or a throwaway environment.

Install Node.js and npm

sudo apt install -y nodejs npm

WHY the -y flag: The -y flag auto-confirms the installation prompt without requiring you to type “yes.” On a server without a GUI, interactive prompts can hang automated scripts.

Ubuntu 26.04’s universe repository packages Node.js and npm as separate packages, which is why this command installs 350+ dependency packages. That is normal behavior and not an error.

Expected output (abbreviated):

The following NEW packages will be installed:
  nodejs npm ...
0 upgraded, 353 newly installed

Verify the APT Install

node --version && npm --version

Expected output:

v22.22.1
9.2.0

Run a Quick Sanity Check

node -e "console.log('Node.js ' + process.version + ' is active')"

WHY run this check: Checking node --version only confirms the binary is in your $PATH. Running actual JavaScript confirms the V8 runtime is functional. These are two different things, and a broken install can satisfy the first check while failing the second.

Expected output:

Node.js v22.22.1 is active

If you need a more current version of npm or Node.js, the APT method is not your best option. Move to the NodeSource method instead.

Step 3: Install Node.js via NodeSource PPA (Recommended for Production Servers)

NodeSource maintains a dedicated APT repository with up-to-date Node.js releases. This is the method I use on production Ubuntu servers because it gives you current npm, automatic security updates via apt upgrade, and predictable package behavior.

Why NodeSource Over the Ubuntu Repo?

NodeSource uses a nodistro APT suite, meaning it works on Ubuntu 26.04 without needing explicit codename support. Their packages also pin at priority 600, which means they take precedence over Ubuntu’s built-in Node packages in future upgrades. You will not accidentally get downgraded by a system update.

Step 3a: Remove Previous Node.js Installs (If Applicable)

If you ran Step 2, clear it out first to avoid version conflicts.

sudo apt remove -y nodejs npm

WHY remove first: Having two Node.js installs from different sources creates $PATH confusion. Your shell may pick up the wrong binary depending on how $PATH is ordered, leading to version mismatches that are frustrating to debug.

Step 3b: Install Required Dependencies

sudo apt install -y curl ca-certificates gnupg

WHY each package matters:

  • curl fetches the NodeSource setup script
  • ca-certificates validates the HTTPS connection to NodeSource servers
  • gnupg verifies the GPG signature on NodeSource packages

Skipping this step causes a “certificate verification failed” error on hardened Ubuntu systems where minimal packages are pre-installed.

Step 3c: Download the NodeSource Setup Script

For Node.js 24.x LTS (recommended for production in 2026):

curl -fsSL https://deb.nodesource.com/setup_24.x -o nodesource_setup.sh

For Node.js 22.x LTS (previous LTS, still in active maintenance):

curl -fsSL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh

WHY download before executing: Many tutorials pipe curl directly into bash: curl ... | sudo bash. That is faster but it means you execute the script without ever seeing what is in it. On a production server, you should always inspect scripts before running them with root privileges. Downloading first gives you that option.

Step 3d: Run the Setup Script

sudo bash nodesource_setup.sh

This adds the NodeSource repository to your APT sources and imports the signing key. You will see output confirming both steps.

Step 3e: Install Node.js

sudo apt install -y nodejs

WHY no separate npm install: Unlike the Ubuntu repo method, NodeSource bundles npm inside the nodejs package. One command installs both.

Verify the NodeSource Install

node --version && npm --version

Expected output:

v24.14.1
10.9.7

That npm version is a significant improvement over the Ubuntu repo’s 9.2.0. You now have access to npm workspaces, improved lock file handling, and better monorepo support.

Step 4: Install Node.js with NVM (Node Version Manager)

NVM is the right choice for developers who work across multiple projects with different Node.js version requirements. It installs Node.js entirely in your home directory (~/.nvm/versions/), which means no sudo required after the initial setup and zero interference with system packages.

Why NVM for Multi-Project Environments

Version conflicts are the number one cause of broken Node.js builds in shared development environments. NVM lets you run Node 22 for a legacy API project and Node 24 for a new microservice on the same machine, in separate terminals, simultaneously.

Step 4a: Install NVM

This command dynamically fetches the latest NVM version number from GitHub, so you always get the current release:

NVM_VER=$(curl -sL https://api.github.com/repos/nvm-sh/nvm/releases/latest | grep tag_name | sed 's/.*"v\([^"]*\)".*/\1/')
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VER}/install.sh | bash

WHY fetch the version dynamically: Hardcoding a version like v0.40.1 means this command goes stale in weeks. The one-liner above always grabs the latest stable NVM release without manual updates.

Step 4b: Reload Your Shell

source ~/.bashrc

WHY this step is not optional: NVM’s installer appends initialization lines to your ~/.bashrc file. Without sourcing it, the nvm command does not exist in your current terminal session. You can also open a new terminal window to achieve the same result.

Step 4c: Install Node.js LTS

nvm install --lts
nvm use --lts
nvm alias default lts/*

WHY set the default alias: Without nvm alias default lts/*, every new terminal session starts without an active Node.js version. The nvm command will exist but node will not be found. Setting the default alias makes the LTS version load automatically in every new shell.

Verify NVM Install and List Versions

node --version && npm --version
nvm ls

Expected output:

v24.14.1
11.11.0

->     v24.14.1
default -> lts/* (-> v24.14.1)
lts/* -> lts/krypton (-> v24.14.1)

To install and switch to a different version:

nvm install 22
nvm use 22
node --version

Step 5: Install Node.js with fnm (Fast Node Manager)

fnm is a Rust-based alternative to NVM. It switches Node.js versions using per-shell symlinks instead of modifying $PATH, which makes version switching near-instant. It is also compatible with .nvmrc and .node-version files, so you can use it in projects that were originally set up with NVM.

Step 5a: Install the Prerequisite and fnm

sudo apt install -y unzip
curl -fsSL https://fnm.vercel.app/install | bash

WHY install unzip first: Ubuntu 26.04 Server does not ship with unzip by default. The fnm installer needs it to extract its Rust binary archive. Without it, the install will fail silently or throw a confusing error.

Step 5b: Load fnm Into Your Shell

export PATH="$HOME/.local/share/fnm:$PATH"
eval "$(fnm env)"

Step 5c: Install and Activate Node.js

fnm install --lts
fnm use lts-latest

Important: fnm install latest does NOT work. Use --lts for the LTS line or a major version number like fnm install 24 for a specific release.

Verify fnm Install

node --version && npm --version

Expected output:

v24.14.1
11.11.0

Step 6: Verify Your Installation With a Live HTTP Server Test

Regardless of which method you used, run this test before calling the install complete. A version check tells you the binary exists. A live server test tells you Node.js actually works.

node -e "
const http = require('http');
const server = http.createServer((req, res) => {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Node.js ' + process.version + ' running on Ubuntu 26.04\n');
});
server.listen(3000, () => console.log('Listening on port 3000'));
"

Open a second terminal and test the response:

curl http://localhost:3000

Expected output:

Node.js v24.14.1 running on Ubuntu 26.04

Press Ctrl+C to stop the test server.

WHY this test matters: This confirms the V8 runtime is functional, the event loop is working, and your system allows TCP binding on port 3000. All three of those can fail independently on a hardened server.

Also check your npm prefix, especially if you installed via NVM:

npm config get prefix

On NVM installs, this should return ~/.nvm/versions/node/v24.14.1. On system installs (APT/NodeSource), it returns /usr. A mismatched prefix causes “permission denied” errors when installing global npm packages, which is one of the most common post-install headaches.

Troubleshooting Common Errors

Even on a clean Ubuntu 26.04 install, these five errors come up regularly.

Error Root Cause Fix
node: command not found after NVM install Shell not reloaded Run source ~/.bashrc or open a new terminal
npm WARN EACCES permission denied on global install npm prefix points to /usr Run npm config set prefix ~/.npm-global and add it to $PATH
curl: (60) SSL certificate problem Missing ca-certificates sudo apt install -y ca-certificates
nvm: command not found in cron jobs or scripts NVM not loaded in non-interactive shells Add the NVM init block to ~/.profile instead of ~/.bashrc
NodeSource setup_24.x returns 404 Incorrect URL format Check the exact URL on deb.nodesource.com docs; avoid typos in the version number

On the EACCES error specifically: This is the most common issue after a system-wide APT or NodeSource install. When you try to run npm install -g for tools like PM2 or TypeScript, npm tries to write to /usr/lib/node_modules which requires root. The correct fix is not sudo npm install -g; that creates files owned by root which cause their own problems. Set a user-owned global prefix instead:

mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Next Steps After Installing Node.js on Ubuntu 26.04

With Node.js running, here are the three most practical next steps for a real server setup:

1. Install PM2 for process management:

npm install -g pm2
pm2 startup

PM2 keeps your Node.js application running after the terminal closes, auto-restarts it on crashes, and survives server reboots. Running node app.js directly in a terminal is fine for testing but not for production.

2. Configure Nginx as a reverse proxy:

Do not expose port 3000 directly on a public IP. Put Nginx in front of your Node.js app to handle port 80/443, SSL termination, and rate limiting. This is the standard production architecture.

3. Open only the ports you need:

sudo ufw allow 22/tcp     # SSH - keep this
sudo ufw allow 80/tcp     # HTTP
sudo ufw allow 443/tcp    # HTTPS
sudo ufw enable

Do not leave port 3000 open in production. That port is for local testing only.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!
r00t is a Linux Systems Administrator and open-source advocate with over ten years of hands-on experience in server infrastructure, system hardening, and performance tuning. Having worked across distributions such as Debian, Arch, RHEL, and Ubuntu, he brings real-world depth to every article published on this blog. r00t writes to bridge the gap between complex sysadmin concepts and practical, everyday application — whether you are configuring your first server or optimizing a production environment. Based in New York, US, he is a firm believer that knowledge, like open-source software, is best when shared freely.

Related Posts