How to Install Node.js and npm on Ubuntu 26.04
Node.js is an open-source JavaScript runtime built on Chrome’s V8 engine. It lets you run JavaScript outside the browser and is commonly used for APIs, command-line tools, and server-side applications. npm is the default package manager for Node.js.
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
v25.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.x, 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> |
| 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:
Terminal
sudo apt update
sudo apt install ca-certificates curl gnupg
Import the NodeSource GPG key:
Terminal
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.gpg
NodeSource provides the following versions:
- v25.x – The current release.
- v24.x – The latest LTS version (Krypton).
- v22.x – Maintenance LTS version (Jod).
We will install Node.js version 24.x. Change NODE_MAJOR=24 to your preferred version if needed:
Terminal
NODE_MAJOR=24
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
Install Node.js and npm:
Terminal
sudo apt update
sudo apt install nodejs
The nodejs package includes both node and npm binaries.
Verify the installation:
Terminal
node --version
You should see output similar to this:
v24.x
Terminal
npm --version
The output will show the npm version bundled with the installed Node.js release:
11.x
To compile native addons from npm, install the development tools:
Terminal
sudo apt install build-essential
Installing 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:
Terminal
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
Do 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_completion
Either close and reopen your terminal or run the commands above to load nvm in the current session.
Verify the installation:
Terminal
nvm -v
0.40.3
List all available Node.js versions:
Terminal
nvm list-remote
...
v22.x (LTS: Jod)
...
v24.x (LTS: Krypton)
...
v25.x
Install the latest Node.js version:
Terminal
nvm install node
...
Now using node v25.x (npm v11.x)
Creating default alias: default -> node (-> v25.x)
Verify the installation:
Terminal
node -v
v25.x
Install additional versions:
Terminal
nvm install --lts
nvm install 22
List installed versions:
Terminal
nvm ls
-> v22.x
v24.x
v25.x
default -> node (-> v25.x)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v25.x) (default)
stable -> 25 (-> v25.x) (default)
lts/* -> lts/krypton (-> v24.x)
lts/jod -> v22.x
lts/krypton -> v24.x
The arrow (-> v22.x) indicates the active version. The default version activates when opening new shells.
Switch to a different version:
Terminal
nvm use 24
Now using node v24.x (npm v11.x)
Change the default version:
Terminal
nvm alias default 24
Installing Node.js and npm from the Ubuntu repository
Ubuntu 26.04 includes Node.js v22.x in its default repositories. This version works well for many applications and receives security updates through Ubuntu.
Install Node.js and npm:
Terminal
sudo apt update
sudo apt install nodejs npm
This installs Node.js along with the tools needed to compile native addons from npm.
Verify the installation:
Terminal
node -v
v22.x
Terminal
npm -v
10.x
Uninstalling Node.js
The uninstall method depends on how you installed Node.js.
NodeSource or Ubuntu repository:
Terminal
sudo apt remove nodejs
sudo apt autoremove
nvm:
Terminal
nvm uninstall 24
To completely remove nvm, delete the ~/.nvm directory and remove the nvm lines from your ~/.bashrc or ~/.zshrc file.
Conclusion
We covered three ways to install Node.js and npm on Ubuntu 26.04. NodeSource provides specific versions, nvm offers flexibility for managing multiple versions, and the Ubuntu repository includes a stable LTS version out of the box.
For more information, see the official Node.js documentation
.




