Node.js releases move fast and older versions reach end-of-life quickly, so it's a good idea to keep your server on a current LTS release. This guide upgrades the system-wide Node.js version installed through NodeSource.
Start by logging into SSH and login as the root user.
Run the following commands, replacing 22 with the major version you want (use a current LTS release such as 22 or 24):
curl -fsSL https://deb.nodesource.com/setup_22.x | bash - apt install -y nodejs
NodeSource replaces any previously installed Node.js version, so this upgrades an existing install in place.
Verify the active version:
node -v
If you use a process manager such as PM2, restart your apps so they pick up the new Node.js binary.