Install NodeJS Ubuntu – Quick & Simple

To install Node.js on Ubuntu, add the NodeSource repository for the LTS line and install the nodejs package with apt. That gives you Node.js 26 LTS with npm included, and node -v confirms it. If you switch Node.js versions between projects, use NVM instead.
Short version
curl -fsSL https://deb.nodesource.com/setup_lts.x -o nodesource_setup.sh
sudo -E bash nodesource_setup.sh
sudo apt install -y nodejs
node -v
npm -vTable of Contents
- Short version
- Adding the Node.js Repository
- Install the Node.js LTS on Ubuntu
- Install a Specific Node.js Version on Ubuntu
- FAQ
- Which Node.js version should I install on Ubuntu?
- How do I check which Node.js version is installed?
- How do I uninstall Node.js installed from NodeSource?
- Should I use apt, NodeSource or NVM to install Node.js?
- Summary
Adding the Node.js Repository
Ubuntu’s own apt repository ships an older Node.js release than the current LTS. To get a current version, we first add the NodeSource repository to our Ubuntu installation. The NodeSource setup script pins one Node.js major version, which makes upgrading or downgrading Node.js versions cumbersome. You can check which Node.js versions are in LTS on the Node.js releases page.
We therefore recommend using NVM (Node Version Manager) instead if you work on several projects.
Install the Node.js LTS on Ubuntu
The setup_lts.x script always points at the current LTS line, which is Node.js 26 as of November 2026. First we download and run the NodeSource setup script, then we install Node.js using apt:
curl -fsSL https://deb.nodesource.com/setup_lts.x -o nodesource_setup.sh
sudo -E bash nodesource_setup.sh
sudo apt install -y nodejs
Install a Specific Node.js Version on Ubuntu
If a project needs an older LTS line, replace lts with the major version. This example installs Node.js 24, which is still in maintenance LTS:
curl -fsSL https://deb.nodesource.com/setup_24.x -o nodesource_setup.sh
sudo -E bash nodesource_setup.sh
sudo apt install -y nodejs
FAQ
Which Node.js version should I install on Ubuntu?
Install the current LTS release unless a project tells you otherwise. As of November 2026 that is Node.js 26, with Node.js 24 still in maintenance LTS. Odd-numbered releases never became LTS, and the new alpha channel is for early testing, so skip both on servers.
How do I check which Node.js version is installed?
Run node -v for Node.js and npm -v for npm. NodeSource’s nodejs package includes npm, so you don’t install it separately. If node -v still shows an old version, run which node to see whether another install, such as NVM or a snap, comes first in your PATH.
How do I uninstall Node.js installed from NodeSource?
Remove the package with sudo apt purge nodejs. Then delete the repository and its key with sudo rm -r /etc/apt/sources.list.d/nodesource.list /etc/apt/keyrings/nodesource.gpg, and run sudo apt update.
Should I use apt, NodeSource or NVM to install Node.js?
Ubuntu’s own apt install nodejs works but gives you an older release. NodeSource gives you a current release system-wide, which suits servers and CI images. NVM installs Node.js per user and switches versions per project, which suits development machines.
Summary
Installing Node.js on Ubuntu is really simple if you don’t have to change Node.js versions often, but if you are developing multiple projects that use different Node.js versions, we highly recommend using NVM instead. Learn how to install NVM in our NVM guide.
More posts
All Web Development
