When you first install Node.js, you usually just grab the latest version from the official website. That works fine for beginners. That works fine for beginners — and if that’s all you want right now and want to go to complexity later when you work with multiple projects, check out my step-by-step post here: Getting Started with Node.js: Setup and Hello World.
But once you start working on multiple projects, you’ll quickly hit a problem:
- Project A might need Node 16
- Project B might need Node 20
Updating Node.js globally could break one project while fixing another. That’s where Node Version Manager (nvm) comes in.
🛠️ What is nvm?
nvm is a tool that lets you install, manage, and switch between multiple versions of Node.js on the same computer.
Think of it like a remote control: you can switch Node.js versions with a single command.
🚀 Why Developers Use nvm
- Multiple projects, different versions → no conflicts.
- Experiment safely → test new Node.js features without breaking old code.
- Team alignment → match the Node.js version your project specifies in
package.jsonor.nvmrc.
📥 Step 1: Install nvm
On macOS
Run this in your terminal:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
Then restart your terminal and verify:
command -v nvm
On Linux
Run the official install script (works on most distros):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
Then reload your shell:
source ~/.bashrc
(or source ~/.zshrc if you use zsh).
Verify installation:
command -v nvm
💡 Note: Some Linux distributions (like Ubuntu) let you install nvm via their package manager (sudo apt install nvm), but this may give you an outdated version. Stick with the script unless you have a specific reason to use the package manager.
On Windows
If you’re on Windows, you’ll need a different version of nvm called nvm-windows. We’ve created a dedicated step-by-step guide for you here:
👉 Setup Node.js on Windows Using nvm
⚙️ Step 2: Basic nvm Commands
Install the latest LTS (recommended for most projects)
nvm install --lts
See which versions you have
nvm ls
Use a specific version
nvm use 20
Install a specific version (e.g., Node.js 16)
nvm install 16
Uninstall a version
nvm uninstall 16
Set a default version for new terminals
nvm alias default 20
🧑💻 Step 3: Real-World Example
Imagine you’re working on two projects:
- Project A needs Node 16
- Project B needs Node 20
You can switch instantly:
cd project-a
nvm use 16
cd ../project-b
nvm use 20
💡 Pro tip: Add a .nvmrc file inside a project with the version number:
16
Now when you run nvm use inside that folder, it automatically switches to Node 16.
🔄 Alternatives
- nvm-windows → for Windows users.
- fnm (Fast Node Manager) → faster, written in Rust.
- Volta → great for pinned project versions.
But for most learners, nvm is the standard.
✅ Key Takeaway
If you want to grow as a developer, install Node.js using nvm. It makes your setup flexible, safe, and professional.
🔄 BONUS: Upgrading to the Latest LTS
One of the best parts of using nvm is how easy it is to keep Node.js up to date.
On Linux/macOS
# Install the latest LTS
nvm install --lts
# Switch to it
nvm use --lts
# (Optional) Make it the default for all new terminals
nvm alias default lts/*
On Windows (nvm-windows)
--lts isn’t supported the same way on Windows. Use lts (without the dashes):
# Install the latest LTS
nvm install lts
# Switch to it (works on recent nvm-windows)
nvm use lts
# Or switch by explicit version:
nvm use 22.20.0
Troubleshooting (Windows):
- If
nvm use --ltsfails with a 404 or similar, drop the dashes:nvm use lts. - If
nvm use ltsdoesn’t pick up, switch by explicit version:nvm use 22.20.0.
Note: nvm-windows doesn’t support
alias default. If you want a version to be active in every new terminal, rerunnvm use <version>(or add it to your shell startup).
✅ After upgrading, confirm:
node -v
npm -v
You should now see the latest LTS (e.g., v22.20.0).
💡 You don’t need to uninstall older versions—keep them for compatibility and switch with nvm use <version> anytime.