Skip to main content

Install Node.js

This guide explains how to install Node.js on your Linux VPS.

Node.js 20 LTS​

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

Node.js 18 LTS​

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

Verification​

node --version
npm --version

With NVM (Node Version Manager)​

NVM allows you to manage multiple Node.js versions:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.bashrc
nvm install 20
nvm use 20

Switch versions​

nvm install 18
nvm use 18
nvm alias default 18
tip

NVM is ideal if you need to work with multiple Node.js versions.