Prerequisites
Before installing Node.js, make sure you have:
- SSH access to your VPS
- Root or sudo privileges
Method 1: Using NodeSource Repository (Recommended)
Connect to your VPS:
ssh hxroot@YOUR_SERVER_IP -p 22
Install Node.js 18.x (LTS):
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
Method 2: Using Ubuntu Repository (Older Version)
apt install nodejs npm -y
Verify Installation
node --version
npm --version
Install PM2 (Process Manager)
npm install -g pm2
✅ Node.js has been installed on your VPS.