How to Install Node.js and npm on Ubuntu 26.04

Ubuntu 26.04 ships Node.js in its own repositories, but the version you get there is not always the version your project needs. Node.js runs JavaScript outside the browser, and npm installs the packages your application depends on. The install method you pick up front decides how much work it takes to change versions later.
This guide covers three ways to install Node.js and npm on Ubuntu 26.04:
- NodeSource repository - Install a specific Node.js version. NodeSource supports Node.js
v26.x,v24.x, andv22.x. - nvm (Node Version Manager) - Manage multiple Node.js versions on the same machine. This is the preferred method for developers.
- Ubuntu repository - The easiest way. Ubuntu 26.04 includes Node.js
v22.22.1, which is suitable for many applications.
Choose the method that fits your needs. If you are not sure which version to install, check the documentation of the application you are deploying.
Quick Reference
| Task | Command |
|---|---|
| Install via NodeSource | sudo apt install nodejs (after adding repo) |
| Install via nvm | nvm install --lts |
| Install via Ubuntu repo | sudo apt install nodejs npm |
| Check Node.js version | node -v |
| Check npm version | npm -v |
| List installed versions (nvm) | nvm ls |
| Switch Node.js version (nvm) | nvm use <version> |
| Set default version (nvm) | nvm alias default <version> |
| Upgrade to a new major (nvm) | nvm install <version> --reinstall-packages-from=<old> |
| Uninstall Node.js | sudo apt remove nodejs or nvm uninstall <version> |
Installing Node.js and npm from NodeSource
NodeSource maintains an APT repository with multiple Node.js versions. Use this method when you need a specific version.
Install the required dependencies:
sudo apt update
sudo apt install ca-certificates curl gnupgImport the NodeSource GPG key:
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpgNodeSource provides the following versions:
- v26.x - The latest LTS version (Lithium).
- v24.x - Maintenance LTS version (Krypton).
- v22.x - Maintenance LTS version (Jod), supported until April 2027.
NodeSource also still publishes a node_20.x repository, but Node.js 20 reached end-of-life in 2026 and no longer receives security fixes. The node_27.x repository contains Node.js 27 alpha builds, which are meant for testing and should not run in production.
NodeSource provides Debian packages for amd64 and arm64. If dpkg --print-architecture reports another architecture, use the Ubuntu repository or nvm instead.
We will install Node.js version 26.x. If your project requires Node.js 24, set NODE_MAJOR=24 instead:
NODE_MAJOR=26
ARCH=$(dpkg --print-architecture)
sudo tee /etc/apt/sources.list.d/nodesource.sources > /dev/null <<EOF
Types: deb
URIs: https://deb.nodesource.com/node_${NODE_MAJOR}.x
Suites: nodistro
Components: main
Architectures: ${ARCH}
Signed-By: /etc/apt/keyrings/nodesource.gpg
EOFInstall Node.js and npm:
sudo apt update
sudo apt install nodejsThe nodejs package includes the node, npm, and npx binaries.
Verify the installation:
node --versionYou should see output similar to this:
v26.13.1npm --versionThe output will show the npm version bundled with the installed Node.js release:
11.20.0After npm is installed, see the npm command guide for package installs, updates, scripts, and lock-file based installs.
If you prefer a package manager that keeps one copy of each package version on disk, see the pnpm command guide
. pnpm can also install Node.js itself with pnpm runtime set node lts -g.
To compile native addons from npm, install the development tools:
sudo apt install build-essentialInstalling Node.js and npm using NVM
NVM (Node Version Manager) is a bash script that lets you manage multiple Node.js versions per user. This is the preferred method for developers who need to switch between versions.
Download and install nvm:
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bashDo not use sudo
, as it will enable nvm for the root user only.
The script clones the repository to ~/.nvm and adds the required lines to your shell profile:
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completionEither close and reopen your terminal or run the commands above to load nvm in the current session.
Verify the installation:
nvm -v0.41.0List all available Node.js versions:
nvm list-remote...
v22.23.5 (Latest LTS: Jod)
...
v24.22.3 (Latest LTS: Krypton)
...
v26.13.1 (Latest LTS: Lithium) (Latest: node)The (Latest: node) label marks the newest release, the version the node alias points to. Node.js 26 is now an LTS line, so the newest release and the latest LTS release are the same version.
Install the latest LTS version:
nvm install --ltsInstalling latest LTS version.
Downloading and installing node v26.13.1...
...
Now using node v26.13.1 (npm v11.20.0)
Creating default alias: default -> lts/* (-> v26.13.1)The first Node.js version you install becomes the default. Here the default alias points to lts/*, the newest LTS release you have installed.
Verify the installation:
node -vv26.13.1Install additional versions:
nvm install 24
nvm install 22List installed versions:
nvm ls-> v22.23.5
v24.22.3
v26.13.1
default -> lts/* (-> v26.13.1)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v26.13.1) (default)
stable -> 26.13 (-> v26.13.1) (default)
lts/* -> lts/lithium (-> v26.13.1)
...
lts/jod -> v22.23.5
lts/krypton -> v24.22.3
lts/lithium -> v26.13.1The arrow (-> v22.23.5) indicates the active version. In this example, installing Node.js 22 selected it, but nvm use can select any installed version. The default version activates when opening new shells.
Switch to a different version:
nvm use 24Now using node v24.22.3 (npm v11.19.1)Change the default version:
nvm alias default 24Installing Node.js and npm from the Ubuntu repository
Ubuntu 26.04 includes Node.js v22.22.1 in its default repositories. This version works well for many applications. The package comes from the universe component and has not been updated since the 26.04 release. The upstream Node.js 22 line is already at v22.23.5.
Install Node.js and npm:
sudo apt update
sudo apt install nodejs npmUbuntu packages nodejs and npm separately, so both names are needed here.
Verify the installation:
node -vv22.22.1npm -v9.2.0Ubuntu ships an older npm than the one bundled with Node.js 22 upstream, which is worth knowing if a project expects a newer npm. To compile native addons from npm packages, install the build tools as well:
sudo apt install build-essentialUpgrading Node.js
Moving to a newer release line works differently for each installation method.
If you installed Node.js from NodeSource, point the repository file at the new release line and reinstall the package. This example moves an existing Node.js 24 install up to Node.js 26:
SOURCE_FILE=/etc/apt/sources.list.d/nodesource.sources
[ -f "$SOURCE_FILE" ] || SOURCE_FILE=/etc/apt/sources.list.d/nodesource.list
sudo sed -i 's#node_24\.x#node_26.x#' "$SOURCE_FILE"
sudo apt update
sudo apt install nodejsAPT replaces the installed nodejs package in place, so you do not need to remove the old version first. Packages with compiled native addons may still need to be reinstalled against the new Node.js version.
The Ubuntu repository only offers the release line that shipped with 26.04, so sudo apt upgrade keeps you on Node.js 22. To reach a newer version, switch to NodeSource or nvm using one of the methods above.
With nvm, install the new version and bring your global packages along in the same command:
nvm install 26 --reinstall-packages-from=24The --reinstall-packages-from option reinstalls every global npm package from the version you name, which saves setting them up by hand. The older version stays on disk, so you can switch back to it while you test.
Troubleshooting
npm: command not found after installing from Ubuntu
Ubuntu splits Node.js and npm into separate packages. Install npm with sudo apt install npm, or use NodeSource or nvm, which both bundle npm with Node.js.
node: command not found after installing nvm
nvm loads from your shell profile, so it is not available until that profile runs. Close and reopen your terminal, or load it in the current shell:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"nvm works in one terminal but not another
Check that the nvm lines were added to the shell file you actually use, such as ~/.bashrc, ~/.zshrc, or ~/.profile.
APT still installs the old version after adding NodeSource
Run sudo apt update after writing the repository file, then confirm the candidate version with apt policy nodejs. If Ubuntu’s package still wins, the repository file was not written correctly.
Permission errors installing global npm packages
Avoid working around these with sudo, since it leaves root-owned files in your home directory. On a development machine, nvm avoids the problem because global packages are installed under your own user account.
Uninstalling Node.js
The uninstall method depends on how you installed Node.js.
NodeSource or Ubuntu repository:
sudo apt remove nodejs npm
sudo apt autoremoveIf you used NodeSource, also delete the repository file and the signing key:
sudo rm /etc/apt/sources.list.d/nodesource.sources /etc/apt/keyrings/nodesource.gpg
sudo apt updatenvm:
nvm uninstall 24To completely remove nvm, delete the ~/.nvm directory and remove the nvm lines from your ~/.bashrc or ~/.zshrc file.
Conclusion
If you are deploying rather than experimenting, install an LTS release and pin it. A release in the Current phase may later enter LTS, while a release line that does not enter LTS has a much shorter support window. Check the Node.js releases page for end-of-life dates before you commit to a version.
To put Node.js into production with PM2 and Nginx, see How to Deploy a Node.js Application on Ubuntu 26.04 .
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 1000+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page