Programming languages · Beginner · 14 min
How to Install Node.js 26 LTS on Ubuntu 26.04
By Padding · Updated 15 Nov 2026
Ubuntu 26.04.1 LTS · Node.js 26 LTS
You will install Node.js 26 LTS with npm from the NodeSource apt repository on Ubuntu 26.04 so that apt keeps it patched, run a first script, set up global npm packages without sudo, and learn the checksum-verified tarball route as an alternative.
On this page
Node.js runs JavaScript outside the browser. It is the base for web servers, build tools and command-line programs. Node.js 26 is a Long Term Support (LTS) release, which means it gets security fixes for years and is the line to choose for production.
There are several ways to install it on Ubuntu, and the one you pick decides who patches it:
- The NodeSource apt repository, used here. It is a signed apt source that carries current Node.js builds.
aptthen updates Node.js along with the rest of the system, which is what you want on a server. - The official tarball from nodejs.org. You get any version you like, and no root access is needed, but nothing updates it for you. It is shown in the last step.
- A version manager such as nvm, which suits a development machine where you switch between versions. It is not covered here.
Ubuntu's own repositories also carry a nodejs package, but it is an older version than the current LTS, so it does not give you Node.js 26.
Step 1 · Add the NodeSource repository
Install the tools needed to fetch and trust a repository key:
sudo apt update
sudo apt install -y curl ca-certificates gnupgDownload NodeSource's signing key and store it in a keyring file that only this repository will use. Then add the repository for the 26.x line. The signed-by option limits that key to this one source:
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor --yes -o /usr/share/keyrings/nodesource.gpg
echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_26.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt updateCheck it worked
apt update lists deb.nodesource.com among its sources without any key error. Ask which version apt would install:
apt-cache policy nodejsThe Candidate line shows a 26. version with nodesource in it, and the table below it shows https://deb.nodesource.com/node_26.x nodistro/main.
Troubleshooting
NO_PUBKEY or The following signatures couldn't be verified means the key file is missing or the signed-by path in the source line does not match it. Check that /usr/share/keyrings/nodesource.gpg exists. A 404 on apt update means the repository line has a typo.
Step 2 · Install Node.js
sudo apt install -y nodejs
node --version
npm --versionThe package nodejs includes npm, the package manager, so you do not install it separately.
Check it worked
node --version prints v26. followed by the minor and patch numbers, and npm --version prints a version number.
Step 3 · Run a first script
Write a short program, and run it. It prints the Node.js version, then does a little work to prove the runtime behaves:
mkdir -p ~/node-hello
cd ~/node-hello
cat > hello.mjs <<'JS'
const name = process.argv[2] ?? "world";
console.log(`Hello, ${name}!`);
console.log(`Running on Node.js ${process.versions.node}`);
console.log([3, 1, 2].toSorted().join(","));
JS
node hello.mjs AdaThe .mjs extension tells Node.js to treat the file as an ES module, the modern import and export syntax. process.argv holds the command-line words, and the first one you type is at index 2, after the program and the script. You can also try the interactive prompt with node and leave it with .exit.
Check it worked
The output is Hello, Ada!, then Running on Node.js 26. and the full version, then 1,2,3.
Step 4 · Install global tools without sudo
npm install -g installs a package so it works from any folder. By default it writes to a system folder, which needs root. Running npm as root is a bad habit, because a package's install scripts then run with full control of the machine. Point npm at a folder in your home directory instead:
mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
export PATH="$HOME/.npm-global/bin:$PATH"
npm install -g cowsay
cowsay "Node.js 26"npm config set writes the setting to ~/.npmrc. The export line adds the new bin folder to your path for this shell. To keep it, add the same line to the end of ~/.profile, then log in again. Global packages are for command-line tools. Libraries your project imports belong in the project's own package.json, installed without -g.
Check it worked
cowsay prints a speech bubble containing Node.js 26. To remove the tool, run npm uninstall -g cowsay.
Step 5 · Keep Node.js up to date
Because the NodeSource repository is an apt source, updates arrive through the usual commands. Within the 26.x line, you get patch and security releases here:
sudo apt update
sudo apt install --only-upgrade nodejsIf a service of yours runs on Node.js, restart it after the upgrade, since a running process keeps using the old binary. When 26 reaches the end of its life, you move to the next LTS by changing node_26.x in /etc/apt/sources.list.d/nodesource.list to the new line, running sudo apt update, and installing nodejs. Check the release schedule at nodejs.org/en/about/previous-releases before you rely on a date.
Step 6 · The tarball route
If you cannot use a third-party repository, or need a user-only install, use the official release archive from nodejs.org. It publishes a SHASUMS256.txt file listing the SHA-256 of every download, and the check below confirms that your download is intact. Nothing patches this install. To upgrade, repeat these steps with a newer version and replace the folder.
This puts it in /opt/node-26, separate from the apt install, and picks the right file for your processor:
cd "$(mktemp -d)"
case "$(uname -m)" in
x86_64) ARCH=x64 ;;
aarch64) ARCH=arm64 ;;
*) echo "Unsupported processor: $(uname -m)"; false ;;
esac
curl -fsSLO "https://nodejs.org/dist/latest-v26.x/SHASUMS256.txt"
FILE=$(grep -oE "node-v26\.[0-9]+\.[0-9]+-linux-${ARCH}\.tar\.xz" SHASUMS256.txt | head -n 1)
curl -fsSLO "https://nodejs.org/dist/latest-v26.x/${FILE}"
grep " ${FILE}\$" SHASUMS256.txt | sha256sum -c -If the architecture line printed Unsupported processor, stop here. The last line must print <file>: OK. If not, do not unpack the file. Then install it:
sudo apt install -y xz-utils
sudo mkdir -p /opt/node-26
sudo tar -xJf "${FILE}" -C /opt/node-26 --strip-components=1
/opt/node-26/bin/node --versionUse it by its full path, or put /opt/node-26/bin ahead of other folders on your path. The checksum file comes from the same site as the download, so it catches a damaged download, not a compromised site. The Node.js project also publishes a signed copy, SHASUMS256.txt.asc, and a list of release keys at github.com/nodejs/release-keys if you need to verify the signature too.
Step 7 · Remove it
To undo the tutorial, remove the packages, the repository and the files you created. The first command undoes the npm prefix setting, which needs npm to still be installed, and the nodejs package takes npm with it:
npm config delete prefix
rm -rf ~/node-hello ~/.npm-global
sudo apt remove -y nodejs
sudo rm -f /etc/apt/sources.list.d/nodesource.list /usr/share/keyrings/nodesource.gpg
sudo rm -rf /opt/node-26
sudo apt updateCheck it worked
command -v node prints nothing, and apt-cache policy nodejs no longer lists deb.nodesource.com.
Next steps
- Build and run a small web app in a container: write a Dockerfile for a Node.js app.
- Put your app behind a web server: reverse proxy a Node.js app with Nginx.
- Start a typed project: set up a TypeScript 7 project.
Related tutorials
- How to Write and Run Your First Web Server in GoYou will write a web server in Go 1.27 using only the standard library, with path routes, a JSON endpoint, a POST handler, timeouts and a clean shutdown, then test the handlers without opening a port and build the server into one binary.
- How to Write and Run Tests in Python with pytestYou will install pytest 9.2 in a uv project, write tests for a small price-parsing module, run many cases from one test with parametrize, read a failure and fix the code, and use a fixture that gives each test its own temporary folder.
- How to Set Up a TypeScript 7 Project from ScratchYou will create a Node.js 26 project, install TypeScript 7, write a tsconfig.json you understand, compile two files to JavaScript, watch the compiler catch a type error, and add npm scripts for building, checking and running.
Need this done for you?
Padding does this work for growing companies, from the first diagnosis to a system that keeps working.
Get new tutorials