How to Install Node.js on Ubuntu 26.04 LTS: Packages or Source
Three ways to install Node.js on Ubuntu 26.04 LTS: Ubuntu's package, the NodeSource repository, or compiling the current LTS release from source.
This guide shows three ways to install Node.js on Ubuntu 26.04 LTS: the package from Ubuntu's archive, the NodeSource repository for a newer release line, and compiling Node.js from the official source tarball. The steps are the same on Ubuntu 24.04 LTS except where noted. Ubuntu 14.04 and the Node.js 0.10 series that was current at the time are both long out of support and should not be used on a server that faces the internet.
Which Node.js version to install
Node.js publishes a new major version regularly and keeps selected ones as long-term support (LTS) lines. Production servers should run an LTS line. As of November 2026:
| Release line | Codename | Status | End of life |
|---|---|---|---|
| Node.js 26 | Lithium | Active LTS | April 2029 |
| Node.js 24 | Krypton | Maintenance LTS | April 2028 |
| Node.js 22 | Jod | Maintenance LTS | April 2027 |
Node.js 20 and older are end-of-life. The three installation methods compare as follows:
| Method | Version you get | Updates |
|---|---|---|
| Ubuntu package | Node.js 22 on Ubuntu 26.04; Node.js 18 on Ubuntu 24.04 | Through apt, from Ubuntu |
| NodeSource repository | The release line you choose (22, 24 or 26) | Through apt, from NodeSource |
| Build from source | Exactly the version you download | Manual: rebuild for every release |
Use only one method per server. If you only need Node.js to run an application, a package is faster and easier to keep patched; build from source when you need a version or build option that no package provides.
Requirements
- A server running Ubuntu 26.04 LTS or 24.04 LTS on a 64-bit x86 or ARM processor.
- A user with
sudorights. - For the source build only: several gigabytes of free disk space and as much memory as you can spare. The Node.js build documentation states that compiling with four parallel jobs typically needs at least 8 GB of RAM.
Option 1: Install the Ubuntu package
Ubuntu ships Node.js and npm as separate packages in the universe component:
sudo apt update
sudo apt install nodejs npm
Check the versions:
node -v
npm -v
On Ubuntu 26.04 this installs Node.js 22, which upstream maintains until April 2027. On Ubuntu 24.04 the package is Node.js 18, a line that upstream no longer supports, so use one of the other two options there.
Option 2: Install from the NodeSource repository
NodeSource publishes .deb packages for each supported release line. Its setup script adds the repository and signing key for the line named in the URL. Download the script for Node.js 26:
sudo apt install -y curl
curl -fsSL https://deb.nodesource.com/setup_26.x -o nodesource_setup.sh
The script runs as root, so read it before you execute it:
less nodesource_setup.sh
Run it and install Node.js:
sudo -E bash nodesource_setup.sh
sudo apt install -y nodejs
Verify the installation:
node -v
npm -v
The NodeSource nodejs package already contains npm; do not install Ubuntu's npm package next to it. For another line, change the number in the URL (setup_24.x, setup_22.x) or use setup_lts.x to follow the newest LTS line.
To remove Node.js and the repository again:
sudo apt purge nodejs
sudo rm -r /etc/apt/sources.list.d/nodesource.list
sudo rm -r /etc/apt/keyrings/nodesource.gpg
Option 3: Build Node.js from source
Install the build tools
Node.js needs a recent C++ compiler (GCC 13.2 or newer, or Clang 19.1 or newer), GNU Make and Python 3. The default compiler on Ubuntu 26.04 is GCC 15; Ubuntu 24.04 ships GCC 13.2, which just meets the minimum for the current sources.
sudo apt update
sudo apt install python3 python3-pip g++ gcc make curl
Download and verify the source
Take the tarball from nodejs.org, not from the development branch on GitHub, which is not a tested release. Look up the current version number of the line you want on the Node.js download page; the commands below use v26.13.1 as an example, so set the variable to the version you chose:
cd ~
NODE_VERSION=v26.13.1
curl -fsSLO https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION.tar.gz
curl -fsSLO https://nodejs.org/dist/$NODE_VERSION/SHASUMS256.txt
Compare the checksum of the download with the published list. The command must print OK:
grep "node-$NODE_VERSION.tar.gz" SHASUMS256.txt | sha256sum -c -
Unpack the archive and change into the source directory. Keep the path free of spaces; the build can fail otherwise.
tar -xzf node-$NODE_VERSION.tar.gz
cd node-$NODE_VERSION
Configure and compile
./configure
make -j4
The number after -j is how many compile jobs run in parallel. Four jobs need roughly 8 GB of RAM, so on a small VPS lower it (make -j2 or plain make) or add swap space first. If the compiler is killed part-way through, the server ran out of memory. Expect the build to take a long time on a machine with few CPU cores; run it inside tmux or screen so a dropped SSH session does not interrupt it.
Test and install
Confirm that the new binary works before installing it:
./node -e "console.log('Hello from Node.js ' + process.version)"
Optionally run the test suite with make test-only. Then install into /usr/local:
sudo make install
Check the installed versions:
node -v
npm -v
Keep the source directory if you can: sudo make uninstall, run from it, removes the files again.
Keep Node.js updated
Packages from Ubuntu or NodeSource are updated with the rest of the system:
sudo apt update
sudo apt upgrade
A source build is not updated by anything. Node.js publishes security releases several times a year; for each one, download the new tarball, repeat the build and run sudo make install again. Restart your Node.js applications after any update so they run on the new binary.
Frequently asked questions
Why is the Ubuntu package older than the current Node.js release?
Ubuntu freezes the major version of a package when a release is published and then only backports fixes. That gives you a stable target, but the frozen line eventually goes out of upstream support, as Node.js 18 on Ubuntu 24.04 has. Use NodeSource or a source build when you need a newer line.
Why is node not found after make install?
The source build installs to /usr/local/bin. That directory is in the default PATH on Ubuntu, but your shell may have cached the old lookup: run hash -r or open a new session. If an Ubuntu or NodeSource package is also installed, which -a node shows both copies; remove the one you do not want.
Should I run several Node.js versions with a version manager instead?
A per-user version manager is convenient on a development machine where projects need different versions. On a server that runs one application under a service account, a system-wide installation from a package or from source is simpler to reason about and to keep patched.
Can I build on a server with 1 GB of RAM?
It is possible with a single job and a large swap file, but slow. A practical alternative is to use the NodeSource package, or to build on a larger machine with the same Ubuntu release and architecture and copy the result.