Admin User
May 31, 2025 05:38 PM · 5 min read
NVM (Node Version Manager) lets you install and manage multiple versions of Node.js on a single system. It's perfect for developers juggling projects with different Node requirements.
Step 1: Download and run the install script
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
Step 2: Load NVM into your terminal
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Tip: To make NVM load automatically, add the above block to your ~/.bashrc
, ~/.zshrc
, or ~/.profile
.
Step 3: Verify installation
nvm --version
List available Node.js versions:
nvm ls-remote
Install the latest LTS version:
nvm install --lts
Or install a specific version:
nvm install 18.19.0
Verify installation:
node -v npm -v
Set a default Node version globally:
nvm alias default 18.19.0
From now on, every new terminal session will use this version unless overridden.
If you have multiple versions installed:
nvm use 16.20.0
To list all installed versions:
nvm ls
To remove a version you no longer need:
nvm uninstall 16.20.0
npm is automatically installed with Node.js via NVM. Check versions:
which node which npm
They will typically point to paths like:
~/.nvm/versions/node/v18.19.0/bin/node
Using NVM on Ubuntu keeps your Node.js environment clean, flexible, and up to date. You can switch Node versions per project, test backward compatibility, or quickly adopt new releases—all without affecting your global system setup.