Updated: 18 November 2026 · Applies to: Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9 with Node.js 24 LTS

Node.js runs JavaScript on the server. Install the current LTS version from the NodeSource repository.

The operating system versions in the original guide (CentOS 7, Ubuntu 16.04/18.04, Debian 8/9) are no longer supported, so this guide uses Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9.

Install Node.js (current LTS)

Use the NodeSource packages for the current Long-Term-Support release (24.x at the time of writing; check nodejs.org):

curl -fsSL https://deb.nodesource.com/setup_24.x | bash -    # Ubuntu / Debian
apt install nodejs

curl -fsSL https://rpm.nodesource.com/setup_24.x | bash -    # AlmaLinux / Rocky
dnf install nodejs

Check with node -v and npm -v.

Tip: For development machines, or several Node versions side by side, use nvm instead: install it from its GitHub page, then nvm install --lts.

Run an app with PM2

npm install -g pm2
pm2 start app.js --name myapp
pm2 startup && pm2 save

PM2 restarts the app if it crashes and after reboots. Put Nginx in front of it for HTTPS.

Update or switch the Node.js version

  • Updates within the same major version arrive with apt upgrade or dnf upgrade.
  • To move to a newer LTS, run the NodeSource setup script for that version (for example setup_26.x once 26 is LTS) and install nodejs again. Test your app first: native modules may need npm rebuild.
  • Remove Node.js with apt remove nodejs or dnf remove nodejs.

Common problems

  • EACCES errors with npm install -g: do not use sudo npm for project packages. Install them per project, or set a user prefix: npm config set prefix ~/.npm-global and add ~/.npm-global/bin to your PATH.
  • node: command not found after installing nvm: open a new shell or run source ~/.bashrc.
  • App stops when you close SSH: run it with PM2 or a systemd service instead of in the foreground.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $135 a month.

Was this answer helpful?

Still stuck? Open a ticket