How to install Node.js with nvm (multiple versions)
Updated 11/29/2026
Different projects may require different Node.js versions. nvm (Node Version Manager) lets you install them and switch between them easily.
1. Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
2. Install a Node version
nvm install 20 # latest version 20
nvm install 18
3. Switch between versions
nvm use 18
nvm alias default 20 # the default version
4. Check
node -v
npm -v
Per project version
Put a .nvmrc file in the project with the desired version, then run nvm use in the directory to select it automatically.
In production
To run a Node app reliably, use PM2 or a systemd service, see how to deploy a Node.js app and how to create a systemd service.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
Error tracking for your applications with GlitchTip
Catch production exceptions with the Sentry SDKs on a small server: the project, the DSN, alerts and uptime.
Updated 11/29/2026Dev environmentsTest your application's email with smtp4dev
Send the email from Laravel, WordPress, Node or Python to a test SMTP server and read it in a web inbox, without it ever reaching real customers.
Updated 11/29/2026Dev environmentsHow to set up a staging environment
Test changes on a copy of production before shipping them, to avoid surprises.
Updated 11/29/2026