How do I install Node.js on my VPS?
In this article
You need Node.js for things like Discord bots, web apps and modern tools such as AI agents. The obvious apt install nodejs is not a good idea for that: Ubuntu and Debian give you an old version that way. Ubuntu 24.04 installs Node.js 18 and Ubuntu 22.04 even Node.js 12, and neither is maintained by the Node.js project any more. Many current programs won't start on them; OpenClaw, for example, needs at least Node.js 24.16. In this guide you install the current LTS version the official way and then check the version. The steps are for a Linux VPS running Ubuntu or Debian; on a Windows VPS, use the installer from nodejs.org.
Which version should you choose?
Choose an LTS version (Long Term Support): it gets security updates for years. Since 28 October 2026 that is Node.js 26, the version used in the commands below. Node.js 24 is still maintained until 30 April 2028; if a program specifically asks for version 24, replace 26 with 24. You can see which versions are currently LTS on nodejs.org.
There are two official routes. Pick one: mixing them leads to confusion about which node is actually running.
- NodeSource (recommended for a server): Node.js is installed as a regular package in
/usr/bin/node, for all users and services, and updates arrive withapt upgrade. - nvm (Node Version Manager): installs Node.js per user in the home directory. Handy if you want several versions side by side. This method is also shown on the nodejs.org download page.
Preparation: remove an old version
Connect to your VPS over SSH (see connecting to your VPS over SSH). If you are logged in as root, you can simply leave sudo in front of the commands. First check whether Node.js is already installed:
node -v
If you get command not found, go straight to one of the methods. If you see an old version, such as v18.19.1 or v12.22.9, remove it first. Otherwise the installation stops on a conflict with the libnode-dev package:
sudo apt remove -y nodejs npm libnode-dev
sudo apt autoremove -y
Method 1: NodeSource (recommended)
Run these commands one after the other:
sudo apt update
sudo apt install -y curl
curl -fsSL https://deb.nodesource.com/setup_26.x -o nodesource_setup.sh
sudo -E bash nodesource_setup.sh
sudo apt install -y nodejs
The NodeSource script adds their package repository and signing key to apt; the last line installs Node.js. npm is included, so don't install it separately. If you want to see what the script does first, view it before the fourth line with less nodesource_setup.sh.
Method 2: nvm (per user)
Log in as the user who will run Node.js, because nvm puts everything in that user's home directory. A bare installation sometimes lacks curl and libatomic1 (Node.js won't start without the latter), so the first line installs them:
sudo apt install -y curl libatomic1
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash
\. "$HOME/.nvm/nvm.sh"
nvm install 26
The third line loads nvm into your current session right away; on your next login this happens automatically. You can find the latest nvm version number (here v0.41.0) on GitHub.
Note: a Node.js installed with nvm lives only in your home directory. A systemd service or another user won't find it automatically. If your bot or app has to run as a service, NodeSource is the easier choice.
Check the version
node -v
npm -v
You should now see something like v26.13.0 and 11.20.0. If the Node version starts with v26 (or v24 if you chose that), you're done.
Updating
With NodeSource, new releases within the same line (for example from 26.13 to 26.14) come in with sudo apt update && sudo apt upgrade. To move to a new major version, run that version's setup script and then sudo apt install -y nodejs again. With nvm, nvm install 26 fetches the latest 26.x.
Common problems
trying to overwrite '/usr/include/node/common.gypi': Ubuntu's old Node.js is still installed, together withlibnode-dev. Remove it with the commands under Preparation and then runsudo apt install -y nodejsagain.node -vstill shows the old version: your shell remembers the old path. Typehash -ror log in again.which -a nodeshows which Node.js installations exist; one in~/.nvmtakes priority over the NodeSource one.nvm: command not found: your current session doesn't know nvm yet. Log in again or run\. "$HOME/.nvm/nvm.sh".error while loading shared libraries: libatomic.so.1: install the missing library withsudo apt install -y libatomic1.- Budget VPS (OpenVZ): the official Node.js builds target Linux kernel 4.18 or newer. On OpenVZ you share the kernel with the host; check it with
uname -r. If it is older, Node.js may still work, but it is not officially supported. For heavy Node apps a KVM VPS is the safer choice.
Need help?
Still stuck? Open a ticket via our support page and include the output of node -v and the full error message.
Launch your server in 60 seconds on our own hardware.