Updated: 28 September 2026 · Applies to: Ubuntu 24.04 LTS with Node.js 24 LTS

Ubuntu 18.04 is no longer supported; this guide uses Ubuntu 24.04 LTS.

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.

Your first app

mkdir ~/hello && cd ~/hello
npm init -y
cat > app.js <<'EOF'
const http = require('http');
http.createServer((req, res) => res.end('Hello from Node.js\n')).listen(3000, '127.0.0.1');
EOF
node app.js

Test from the server with curl http://127.0.0.1:3000. Use PM2 to keep it running and Nginx as a reverse proxy for public access.

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