- Vrealmatic
- Ubuntu Server
- Node.js
Node.js on Ubuntu
Servers from the NodeSource apt repository with automatic patches, development machines with nvm.
On a server Node.js comes from a signed apt repository pinned to one LTS line, security updates install themselves and the app runs as a systemd service under its own user. On your computer nvm switches versions per project. The guide covers both, how to move to a new major and how to migrate a server away from nvm.
Contents
01 · Start
Choosing the method and version
There are several ways to get Node.js onto Ubuntu and each fits a different job. On a server you want one version, installed system-wide and patched automatically. On a developer machine you want to switch versions per project. The two needs have different answers.
| Method | Use it for | Updates | Verdict |
|---|---|---|---|
| NodeSource apt repository | Production servers, CI runners | Automatic patches and minor versions within one major (unattended-upgrades) | Recommended for servers |
| nvm | Your own computer, WSL, trying a new version | Manual, per user | Recommended for development |
| Docker image | Apps that already run in containers | By rebuilding the image (e.g. node:26-bookworm-slim) | Good; then Node.js is not installed on the host at all |
Ubuntu archive (apt install nodejs) | Tools that only need some Node.js | Automatic, but the version is old and security fixes for universe come with Ubuntu Pro | Only when the old version is enough |
nvm is built to be installed per user and loaded per shell from ~/.bashrc. systemd does not read .bashrc, so services need hard-coded paths into someone's home directory, symlinks in /usr/local/bin that break with every version change, or extra group membership to read another user's home. Above all, nobody patches it: every Node.js security release means logging in and running nvm install by hand. The apt route solves all of that. If you keep nvm on a server anyway, the older approach is kept in its own chapter.
Which version
Production should run only an LTS line (Active or Maintenance). Lines that are not LTS (Current, and from 2026 Alpha) are for testing. State as of 3 November 2026, according to the Node.js release schedule:
| Line | Status | Supported until | For a server |
|---|---|---|---|
| Node.js 26 (Lithium) | Active LTS since 28 Oct 2026 | 30 Apr 2029 | New servers |
| Node.js 24 (Krypton) | Maintenance LTS | 30 Apr 2028 | Fine for existing apps; plan the move to 26 |
| Node.js 22 (Jod) | Maintenance LTS | 30 Apr 2027 | Upgrade soon |
| Node.js 27 | Alpha, release in April 2027, LTS from October 2027 | 30 Apr 2030 | Not yet |
From Node.js 27 there is one major release a year and every one becomes LTS. The commands below use 26; for another line replace node_26.x with e.g. node_24.x.
- Server: NodeSource repository pinned to one LTS major, patches installed automatically, app as a systemd service under its own user.
- Your computer: nvm, with the project's version in
.nvmrc, the same major as the server. - A new major is a deliberate step: test with nvm locally, then change one line on the server.
02 · Server
Installing from the NodeSource repository
NodeSource builds the official Node.js releases as .deb packages, one repository per major line. You add it the same way as NodeSource's own setup script does, only by hand: you verify the key before apt trusts it and you see every file that is written. Run the commands as your admin user with sudo, not as the application user.
Ubuntu 22.04, 24.04 or 26.04 on amd64 or arm64. If you used nvm for Node.js on this server before, follow Moving a server from nvm after this chapter.
Step 1: Remove Node.js from the Ubuntu archive (if installed)
Packages from the Ubuntu archive (nodejs, npm, libnode-dev) collide with the NodeSource package. Check with apt list --installed 2>/dev/null | grep -E '^(nodejs|npm|libnode)'; with empty output skip this step.
sudo apt purge -y nodejs npm libnode-dev # only if Node.js from the Ubuntu archive is installed
sudo apt autoremove -yStep 2: Download the signing key and check its fingerprint
The key is first saved to a temporary file. Nothing trusts it yet:
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key -o /tmp/nodesource.asc
gpg --show-keys --with-fingerprint /tmp/nodesource.ascpub rsa2048 2016-05-23 [SC]
6F71 F525 2828 41EE DAF8 51B4 2F59 B5F9 9B1B E0B4
uid NSolid <nsolid-gpg@nodesource.com>
sub rsa2048 2016-05-23 [E]The fingerprint must be exactly 6F71 F525 2828 41EE DAF8 51B4 2F59 B5F9 9B1B E0B4 (verified on 3 November 2026; the key is named NSolid, after NodeSource's product, that is correct). If it differs, stop here.
Step 3: Store the key for apt
The key goes to /etc/apt/keyrings and is used only for this one repository (Signed-By below), not for all of apt:
sudo install -d -m 0755 /etc/apt/keyrings
sudo gpg --dearmor --yes -o /etc/apt/keyrings/nodesource.gpg /tmp/nodesource.asc
sudo chmod 644 /etc/apt/keyrings/nodesource.gpg
rm /tmp/nodesource.ascStep 4: Add the node_26.x repository
In the deb822 format that Ubuntu itself uses since 24.04 and that NodeSource's script writes too (works on 22.04 as well). The repository is bound to one major line:
sudo tee /etc/apt/sources.list.d/nodesource.sources <<EOF
Types: deb
URIs: https://deb.nodesource.com/node_26.x
Suites: nodistro
Components: main
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/nodesource.gpg
EOFnodistro is correct: one repository serves all Debian and Ubuntu releases.
Step 5: Prefer the NodeSource package
Priority 600 (above the default 500) makes apt always take nodejs from NodeSource, even if the Ubuntu archive ever offers a package with a higher version string. The pin applies only to the nodejs package; the rest of the system is unaffected.
sudo tee /etc/apt/preferences.d/nodejs <<'EOF'
Package: nodejs
Pin: origin deb.nodesource.com
Pin-Priority: 600
EOFThe file name is the same as the one NodeSource's script uses, so running the script later overwrites it instead of creating a duplicate.
Step 6: Install Node.js
The nodejs package from NodeSource includes npm and npx; do not install the separate npm package from Ubuntu.
sudo apt update && sudo apt install -y nodejsStep 7: Verify
node -v && npm -v
which -a node
apt-cache policy nodejsv26.x.x
11.x.x
/usr/bin/node
nodejs:
Installed: 26.x.x-1nodesource1
Candidate: 26.x.x-1nodesource1
Version table:
*** 26.x.x-1nodesource1 600
600 https://deb.nodesource.com/node_26.x nodistro/main amd64 Packages
…Expected: version 26, a single path /usr/bin/node and a *** next to the line from deb.nodesource.com with priority 600. Another path before /usr/bin/node (e.g. ~/.nvm/… or /usr/local/bin/node) means an older installation shadows the new one, see Troubleshooting.
03 · Server
Automatic security updates
apt upgrade already updates Node.js from the new repository. To have it done automatically like the rest of the system, allow the repository in unattended-upgrades. Because the repository is bound to node_26.x, only patch and minor releases of line 26 arrive automatically, never a jump to the next major.
Step 8: Check that unattended-upgrades runs
systemctl is-enabled unattended-upgrades
cat /etc/apt/apt.conf.d/20auto-upgradesenabled
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";A different output: set it up first following Unattended upgrades.
Step 9: Allow the NodeSource repository
By default unattended-upgrades installs only from the Ubuntu archives. A separate file adds NodeSource to the allowed origins (apt merges the lists from all files), and 50unattended-upgrades stays untouched so a package update cannot overwrite your change:
sudo tee /etc/apt/apt.conf.d/51nodesource-upgrades <<'EOF'
Unattended-Upgrade::Origins-Pattern {
"site=deb.nodesource.com";
};
EOFThe match is by host name (site). Matching by origin (o=…) is not useful here: the NodeSource repository publishes the generic origin . nodistro.
Step 10: Verify with a dry run
sudo unattended-upgrade --dry-run --debug 2>&1 | grep -iE "allowed origins|nodejs"Allowed origins are: o=Ubuntu,a=noble, o=Ubuntu,a=noble-security, …, site=deb.nodesource.comsite=deb.nodesource.com must be in the Allowed origins line. If an update is waiting, a Checking: nodejs line follows. What was really installed is in the log:
grep -i nodejs /var/log/unattended-upgrades/unattended-upgrades.log | tail -n 5The update replaces /usr/bin/node on disk; a running process keeps using the old binary in memory. Security fixes therefore only take effect after a restart of the service. Ubuntu's needrestart can do it automatically depending on its configuration; the command below lists services that still run the old binary. Restart them (sudo systemctl restart myapp) at a time that suits you, or put your app behind a process that can restart without downtime.
sudo needrestart -r l # lists services still running the old binary04 · Server
Running the app as a service
Node.js is now system-wide and owned by root, which is standard. What matters is that the application does not run as root: it gets its own system user without a login, and systemd starts it, restarts it after a crash and starts it again after a reboot. Replace myapp with the name of your application.
Step 11: Create the application user and directories
sudo useradd --system --create-home --home-dir /srv/myapp --shell /usr/sbin/nologin myapp
sudo install -d -o myapp -g myapp -m 0750 /srv/myapp/app /srv/myapp/dataapp is for the code, data for what the app writes (uploads, SQLite, cache). See also user management (in Czech).
Step 12: Copy the code and install dependencies
Put the application into /srv/myapp/app (e.g. a git clone), make it owned by myapp and install exactly what the lock file says, without development dependencies:
cd /srv/myapp/app
sudo -u myapp npm ci --omit=devStep 13: Create the systemd service
ExecStart points to /usr/bin/node, a path that stays the same through every update. No PATH tricks are needed:
[Unit]
Description=My Node.js app
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=myapp
Group=myapp
WorkingDirectory=/srv/myapp/app
Environment=NODE_ENV=production
ExecStart=/usr/bin/node server.js
Restart=on-failure
RestartSec=5
# Hardening
NoNewPrivileges=yes
PrivateTmp=yes
ProtectSystem=strict
ProtectHome=yes
ReadWritePaths=/srv/myapp/data
[Install]
WantedBy=multi-user.targetThe Hardening part makes the whole file system read-only for the app except ReadWritePaths and hides /home. If the app needs to write elsewhere, add the path there. Ports below 1024 (80, 443) belong to a reverse proxy (Caddy, Nginx) in front of the app; do not run Node.js as root for them.
Step 14: Start and enable the service
sudo systemctl daemon-reload
sudo systemctl enable --now myapp
systemctl status myapp --no-pager
journalctl -u myapp -f05 · Server
Moving to a new major version
A major version can break dependencies (native modules, removed APIs), so it is never installed automatically. Change it on purpose, ideally while the current line is still supported: Node.js 26 until 30 April 2029. The example moves to line 27 (LTS from October 2027).
Step 15: Test the app with the new version on your computer
With nvm the new line runs next to the current one:
nvm install 27 && nvm use 27 && npm ci && npm test # on your computer, in the projectStep 16: Switch the repository on the server
One line in the repository file changes. The pin and unattended-upgrades need no change, they match the host, not the version:
sudo sed -i -E 's#node_[0-9]+\.x#node_27.x#' /etc/apt/sources.list.d/nodesource.sources
sudo apt update && sudo apt install -y nodejs
node -v
sudo systemctl restart myappIf the app uses native modules, run sudo -u myapp npm rebuild (or npm ci again) before the restart.
Rolling back to the previous major
Point the repository back to the previous line and install a concrete version from it:
sudo sed -i -E 's#node_[0-9]+\.x#node_26.x#' /etc/apt/sources.list.d/nodesource.sources
sudo apt update
apt list -a nodejs # pick the version to return to
sudo apt install -y --allow-downgrades nodejs=<VERSION>
sudo systemctl restart myapp06 · Alternative
Node.js from the Ubuntu archive
Ubuntu ships its own nodejs package. It is the simplest option, but the version is fixed for the whole life of the Ubuntu release and is usually behind or past upstream support:
| Ubuntu | Node.js in the archive | Upstream support |
|---|---|---|
| 26.04 LTS | 22.22 | until 30 Apr 2027 |
| 24.04 LTS | 18.19 | ended 30 Apr 2025 |
| 22.04 LTS | 12.22 | ended 30 Apr 2022 |
The package is in the universe component: security fixes for it are not guaranteed for free; Canonical provides them through Ubuntu Pro (ESM Apps). npm is a separate package here. Use it when a tool only needs some Node.js (a build script, an older utility), not for an application facing the internet.
apt-cache policy nodejs # which version your Ubuntu offers
sudo apt update && sudo apt install -y nodejs npm07 · Development
nvm on your computer
On your own computer (Linux, Mac, WSL on Windows) nvm is the right tool: several Node.js versions side by side in your home directory, no sudo, a switch per project. Use the same major there as on the server. On Windows without WSL use the separate project nvm-windows or fnm.
Step 17: Install nvm
Check the latest release on GitHub (v0.40.8 when this was written) and read the script before you run it:
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | less # read it firstcurl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash
source ~/.bashrc
nvm --versionThe installer puts nvm in ~/.nvm and adds its loader to ~/.bashrc (or ~/.zshrc). Run it as your normal user, never with sudo.
Step 18: Install Node.js versions
nvm install --lts # current LTS, becomes the default
nvm install 24 # another line next to it
nvm ls # installed versions
nvm use 24 # this shell only
nvm alias default 26 # default for new shellsStep 19: Pin the version per project
.nvmrc in the repository tells everyone (and CI) which line the project uses. Keep it on the same major as the server:
echo "26" > .nvmrc # in the project root, commit it
nvm install # installs the version from .nvmrc
nvm use # switches to itStep 20: Keep it up to date
nvm does not update anything by itself. From time to time:
nvm install --lts --reinstall-packages-from=current # newest LTS patch, keep global packages
nvm ls-remote --lts | tail -n 5 # latest LTS releases
nvm uninstall 22 # remove an old lineTo update nvm itself, run the installer of the new release again; your installed Node.js versions stay.
08 · Tools
pnpm and Yarn through Corepack
pnpm and Yarn are best taken through Corepack: the exact version comes from the packageManager field in package.json, so the server uses the same version as your computer. Corepack is bundled with Node.js up to 24; since Node.js 25 it has to be installed from npm.
Node.js 24
sudo corepack enable # Node.js 24 and older: Corepack is bundledNode.js 25 and newer (26)
sudo npm install -g corepack@latest # Node.js 25 and newer: Corepack is no longer bundled
sudo corepack enablePackages installed with npm install -g are not managed by apt and are not updated by unattended-upgrades. Update them now and then with sudo npm update -g. Install the project's dependencies as the app user:
cd /srv/myapp/app
sudo -u myapp pnpm install --frozen-lockfile --prod09 · Legacy
nvm on a server (older approach)
The original procedure of this guide, kept for servers that already run Node.js through nvm and will stay that way. For a new server use the apt installation; to switch an existing one, see Moving a server from nvm.
No automatic updates: every Node.js security release means nvm install, new symlinks or edited units, and a restart, by hand. The binaries belong to an ordinary account, yet services and sudo node run them; whoever takes over that account runs code as the service or as root. Paths contain the exact version, so links and units must change with every update.
Node.js with NVM can be installed under any account, see below:
- Check the NVM install script
Terminal curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | less - Install NVM
Terminal curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bashNVM is installed with the permissions of the user running the command (you): into the user's home directory (
~/.nvm), and its loader is added to~/.bashrc. - Reload the shell profile so the nvm command is available
Terminal source ~/.bashrc - List the available LTS versions
Terminal nvm list-remote --lts - Install Node.js
Terminal nvm install --lts # current LTS nvm install v26.13.0 # or a specific versionNode.js is installed with the permissions of the user running the command (you).
- Show the active version
Terminal node -v
Node.js installed this way belongs to this user only: node -v works for you, but not for other users nor with sudo node -v. There are two ways to make the node command available to other users and services:
- Symlink
A symlink from
/usr/local/bin/nodeto the Node.js binary in the user's account ($NVM_DIR/versions/node/$(nvm version)/bin/node):Terminal sudo ln -sfn "$NVM_DIR/versions/node/$(nvm version)/bin/node" /usr/local/bin/nodeThe link points to one specific version: after installing another version, run the command again. Since Ubuntu 21.04 home directories have mode 750, so other users reach the target only if they can enter your home (see the group below).
- Environment variable in the service, with group membership
In a systemd service, add an
Environmentvariable whosePATHleads to the Node.js binaries of the user with nvm:/etc/systemd/system/<SERVICE>.service [Unit] Description=My service Wants=network-online.target After=network-online.target [Service] User=<SERVICE_USER> Group=<SERVICE_USER> Type=simple Restart=always RestartSec=5 WorkingDirectory=/directory/to/service/client Environment="PATH=/home/<NVM_USER>/.nvm/versions/node/v26.13.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ExecStart=/home/<NVM_USER>/.nvm/versions/node/v26.13.0/bin/node server.js [Install] WantedBy=multi-user.targetTo make
nodeaccessible, the <SERVICE_USER> must be added to the <NVM_USER> group (it then can read everything group-readable in that home):Terminal sudo usermod -aG <NVM_USER> <SERVICE_USER> sudo systemctl daemon-reload && sudo systemctl restart <SERVICE>After every Node.js update change the version in the unit and restart the service.
Installing Node.js under a system account
- Create the user and its directory
Terminal sudo useradd --system --shell /bin/bash --home-dir /srv/nodejs nodejsusr sudo mkdir -p /srv/nodejs sudo chown nodejsusr:nodejsusr /srv/nodejs - Switch to nodejsusr
Terminal sudo -i -u nodejsusr - Install and enable NVM
The account has no
.bashrcyet; create it first so the installer can add its loader:Terminal touch ~/.bashrc curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bashCheck that
~/.bashrc(nano ~/.bashrc) contains these lines; add them if not:~/.bashrc 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_completionReload the shell profile and check the nvm version:
Terminal source ~/.bashrc nvm --version - Install Node.js
Terminal nvm list-remote --lts # available versions nvm install --lts # current LTS (or a specific one: nvm install v26.13.0) node -v npm -v - Return to your standard user
Terminal exit - Set up shared access to node, npm and npx
The symlinks point to the newest installed version:
Terminal for b in node npm npx; do sudo ln -sfn "$(ls -d /srv/nodejs/.nvm/versions/node/*/bin/$b | sort -V | tail -n1)" "/usr/local/bin/$b" done which node && node -v/srv/nodejshas mode 755, so services reach the binaries without any group membership. Units then useExecStart=/usr/local/bin/node ….
Upgrading / downgrading Node.js under the system account
- Sign in as nodejsusr and reload .bashrc
Terminal sudo -i -u nodejsusr source ~/.bashrc - Install the new Node.js version with NVM
Terminal nvm install vXX.X.X nvm use vXX.X.X nvm alias default vXX.X.X exit - Update the symlinks
Current links are visible with
ls -lh /usr/local/bin. Remove them:Terminal sudo unlink /usr/local/bin/node sudo unlink /usr/local/bin/npm sudo unlink /usr/local/bin/npxCreate new symlinks to the newest version and restart the services that use Node.js:
Terminal for b in node npm npx; do sudo ln -sfn "$(ls -d /srv/nodejs/.nvm/versions/node/*/bin/$b | sort -V | tail -n1)" "/usr/local/bin/$b" done node -v sudo systemctl restart <SERVICE>For a downgrade, the version-sorted command picks the newest installed version; link the required version explicitly instead (
…/versions/node/vXX.X.X/bin/node) or uninstall the newer one first.
Managing package manager tools
Note: Corepack (used below for Yarn and pnpm) is bundled with Node.js up to v24 LTS. Since Node.js 25 it is no longer part of the Node.js distribution: on newer versions install it first as nodejsusr with npm install -g corepack, then use corepack enable as described below.
Shared access for Yarn, if needed
- Sign in as nodejsusr, reload .bashrc and find corepack's yarn
Terminal sudo -i -u nodejsusr source ~/.bashrc corepack enable which yarn - Return to your standard user
Terminal exit - Create the symlink to the corepack path
Terminal sudo ln -sfn /srv/nodejs/.nvm/versions/node/vXX.X.X/bin/yarn /usr/local/bin/yarn - Check availability
Terminal yarn --version
Shared access for pnpm, if needed
- Sign in as nodejsusr, reload .bashrc and enable corepack
Terminal sudo -i -u nodejsusr source ~/.bashrc corepack enable - Prepare pnpm
Terminal corepack prepare pnpm@latest --activate pnpm --version which pnpm exit - Create the symlink to the corepack path
Terminal sudo ln -sfn /srv/nodejs/.nvm/versions/node/vXX.X.X/bin/pnpm /usr/local/bin/pnpm - Check availability
Terminal pnpm --version
The Yarn and pnpm links contain the Node.js version: after a Node.js upgrade run corepack enable in the new version and update them as well.
Useful commands
which node/which corepack: location of Node.js / Corepacknvm ls: installed Node.js versionsnpm -v: npm version (nvm installs a compatible npm with every Node.js version)
Installing next versions
nvm list-remote # available Node.js versions
nvm install vXX.X.X # becomes the active version; the previous one stays (nvm ls)Switching to a selected version
nvm use vXX.X.XSetting the default version
nvm alias default vXX.X.XUninstalling unused versions
nvm uninstall vXX.X.X10 · Migration
Moving a server from nvm
An earlier version of this guide recommended nvm on the server too, with symlinks in /usr/local/bin or a PATH in the systemd unit. This is how to move such a server to the apt installation. First install Node.js from NodeSource (steps 1 to 7).
Step 21: Find what still uses nvm
ls -l /usr/local/bin | grep -i nvm
grep -rl nvm /etc/systemd/system
npm ls -g --depth=0 # as the nvm user: global packages you will need againNote down global packages (pm2 and similar); install them again later with sudo npm install -g, or better as project dependencies.
Step 22: Remove symlinks into nvm
/usr/local/bin comes before /usr/bin in PATH, so old symlinks would keep shadowing the new Node.js. The command deletes only links that point into an .nvm directory:
sudo find /usr/local/bin -maxdepth 1 -type l -lname '*/.nvm/*' -print -delete
hash -r
which -a node # /usr/bin/node onlyStep 23: Point the services to /usr/bin/node
For every unit found in step 21:
sudo systemctl edit --full myapp # ExecStart=/usr/bin/node …, delete Environment="PATH=…/.nvm/…"
sudo systemctl restart myapp
systemctl status myapp --no-pagerStep 24: Clean up
Once all services run on /usr/bin/node, remove the group membership and nvm. The names are from the old guide (nodejsusr, /srv/nodejs), adjust them to yours:
sudo gpasswd -d <SERVICE_USER> <NVM_USER> # the group membership is no longer needed
sudo rm -rf /srv/nodejs/.nvm # nvm of the old system account
sudo userdel nodejsusr && sudo rm -rf /srv/nodejs # only if the account served nothing else11 · Problems
Troubleshooting
node -v shows another version
Another node comes earlier in PATH: nvm loaded from ~/.bashrc, or a symlink in /usr/local/bin. The first line of which -a wins. After removing it run hash -r or open a new shell.
which -a node
type node
echo "$PATH"apt installs the old Ubuntu version
apt-cache policy nodejs does not show deb.nodesource.com with priority 600: the repository did not load (look for errors in sudo apt update) or the pin file is missing. Check steps 4 and 5.
Warning: Target Packages is configured multiple times
The repository is defined twice, typically from an older setup in the one-line format (nodesource.list) next to the new nodesource.sources. Keep one:
ls /etc/apt/sources.list.d/ | grep -i node
sudo rm /etc/apt/sources.list.d/nodesource.list # keep only nodesource.sourcesdpkg: trying to overwrite '/usr/include/node/…'
A development package from the Ubuntu archive is still installed. Remove it and let apt finish the installation:
sudo apt purge -y libnode-dev
sudo apt -f installNO_PUBKEY or The following signatures couldn't be verified
The path in Signed-By does not lead to the key, or the key file is not readable. ls -l /etc/apt/keyrings/nodesource.gpg must show -rw-r--r--; otherwise repeat step 3.
Sources
Official documentation and further reading
The guide is based on the documentation below (verified on 3 Nov 2026):
- NodeSource distributionsThe repository, supported systems and the official setup script.
- Node.js release scheduleLTS lines, their phases and end-of-life dates.
- Node.js releasesCurrent versions and the production recommendation.
- nvmInstallation, .nvmrc and commands.
- unattended-upgradesOrigins-Pattern and the keys it matches on.
- apt_preferences(5)Pinning and priorities.
- systemd.exec(5)User, ProtectSystem, ReadWritePaths and other service options.
- nodejs in UbuntuVersions in each Ubuntu release.
Related
- Unattended upgradesAutomatic security updates on Ubuntu.
- Docker on UbuntuWhen the app runs in a container instead.
- GitDeploying code from GitHub over SSH.
- Securing accessSSH, firewall and 2FA for the server.
How to cite this publication (APA 7)Nepor, V. (2026, October 2). Node.js on Ubuntu: NodeSource apt for Servers, nvm for Development. Vrealmatic. https://vrealmatic.com/ubuntu/nodejs
Need a secure server setup?
We design, secure and document networks and servers.