Linux VPS

Update or switch Node.js versions safely (nvm, NodeSource, cPanel)

Upgrade Node.js to a newer LTS version on a VPS with nvm or NodeSource, or change it in cPanel Setup Node.js App, then rebuild dependencies and restart apps.

IntermediateLinux VPS and cPanel hosting2 min read

Each Node.js major version is supported for about 30 months. Running an end-of-life version means no security fixes, and new packages may refuse to install. This guide shows how to move an app to a newer LTS version with minimal downtime.

Before you start

  • Check your current version with node -v.
  • Read your framework's release notes for the minimum supported Node.js version.
  • Take a backup or snapshot of the app folder. On cPanel, JetBackup keeps daily backups.
  • Test the new version on your computer first: npm ci && npm test && npm run build.

Update with nvm

  1. Install the new version and reinstall your global packages from the old one:
    nvm install 24 --reinstall-packages-from=22
  2. Make it the default for new shells:
    nvm alias default 24
  3. Rebuild the project's native modules:
    cd ~/myapp
    rm -rf node_modules
    npm ci
  4. Update PM2's in-memory daemon and restart apps:
    pm2 update
    pm2 restart all
  5. When everything works, remove the old version: nvm uninstall 22.

Tip: Pin the version per project with an .nvmrc file containing 24. Then nvm use in that folder picks the right version.

Update with NodeSource

NodeSource has one repository per major version, so you switch repository and upgrade.

Ubuntu and Debian

curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -
sudo apt install -y nodejs

AlmaLinux and Rocky Linux

curl -fsSL https://rpm.nodesource.com/setup_24.x | sudo bash -
sudo dnf install -y nodejs

Then reinstall modules with npm ci and restart your apps as above.

Change the version in cPanel

  1. Open cPanel → Software → Setup Node.js App and click the pencil icon next to the app.
  2. Choose the new version in Node.js version and click Save.
  3. Click Run NPM Install so modules are built for the new version.
  4. Click Restart and test your site.

The list of versions is set by the server; see CloudLinux Node.js Selector for details.

Check afterwards

  • node -v shows the new version (in cPanel, run the source command from the app screen first).
  • The app starts without errors in its log.
  • Key pages and API calls work.

Troubleshooting

  • was compiled against a different Node.js version — native modules were built for the old version. Delete node_modules and run npm ci.
  • PM2 still uses the old version — run pm2 update, or set interpreter in the ecosystem file.
  • Build breaks — roll back by selecting the old version and fix the incompatibility locally.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.