Install Node.js on Ubuntu

node-js

Updated August 29, 2026

The safest general approach on Ubuntu is to choose one version manager or one distribution package source and use it consistently. For development work, nvm is convenient because projects often require different Node.js versions.

Install with a version manager

Install nvm by following the current instructions in the nvm repository, then open a new terminal and run:

nvm install --lts
nvm alias default 'lts/*'
node --version
npm --version

The exact nvm installer URL changes over time, so copying it from the project's README is safer than keeping an old blog command.

Use Ubuntu packages instead

Ubuntu also provides Node.js packages through its repositories:

sudo apt update
sudo apt install nodejs npm

Those versions can lag behind the Node.js release line a project expects. Check node --version against the project's engines field or documentation. Do not install nvm and several third-party Node repositories just to make a version number change; remove or document the source you do not use. Finish by running the project's tests, since a successful node --version does not prove that its dependencies are compatible.

Sources

related.

Ruslan Osipov

Ruslan Osipov

About the author