Quick answer: For servers, install a current LTS release of Node.js either from the NodeSource repository (system-wide, good for production) or with nvm (per-user, easy version switching). Avoid the distro's default package — it is often outdated.
Overview
Node.js runs JavaScript on the server — APIs, SSR frontends, bots and build tooling. Version matters: frameworks target specific LTS lines (currently even-numbered releases like 20.x/22.x). NodeSource suits a single production runtime; nvm suits developers juggling versions.
Before you start
- Root/sudo access (NodeSource) or a regular user (nvm).
- Check which Node version your application requires.
Step-by-step guide
Option A — NodeSource (system-wide):
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt -y install nodejs
node -v && npm -v
(RHEL family: use the matching rpm script from the same project, then sudo dnf install nodejs.)
Option B — nvm (per-user):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc
nvm install --lts
nvm use --lts
Run an app as a service — use a process manager so it survives reboots:
sudo npm install -g pm2
pm2 start app.js --name myapp
pm2 startup && pm2 save
Common issues
node: command not foundunder sudo/systemd with nvm: nvm lives in the user shell — use absolute paths or NodeSource for services.- Global npm installs failing with EACCES: with nvm this disappears; otherwise configure a user-level npm prefix instead of sudo.
- App dies on SSH logout: that's expected for foreground processes — use pm2 or a systemd unit.
When to contact support
Application runtime issues are application-level; for server-level problems or resource upgrades, open a ticket.
Frequently asked questions
Should I use NodeSource or nvm?
Use NodeSource for a single system-wide production runtime that works with systemd services; use nvm when you need to switch between Node versions per user or project.
Which Node.js version should I install?
Install the current LTS line (even-numbered, e.g. 20.x or 22.x). LTS releases get long-term security support and are what frameworks test against.
How do I keep my Node app running after I log out?
Run it under a process manager. Install pm2 globally, start the app with "pm2 start app.js", then "pm2 startup" and "pm2 save" make it survive reboots.
Related articles
Ready to get started? Order a VPS at Cloud2Y →
