How to Install NVM, Install Node.js, and Manage Multiple Node Versions (Windows, macOS & Linux)

Author

Amit Verma

Date Published

Install Node.js using NVM

Managing different versions of Node.js is essential for modern development. Some projects need an older version (like Node 14 or 16), while others need the latest LTS version.


NVM (Node Version Manager) makes this easy by allowing you to install, switch, and manage multiple Node.js versions on the same machine.


This guide explains how to:


✅ Install NVM

✅ Install Node.js using NVM

✅ Use multiple Node versions

✅ Switch between versions

✅ Uninstall or set default versions

✅ Works for Windows, macOS, and Linux



🚀 What is NVM?


NVM stands for Node Version Manager.

It is a command-line tool that lets you:

Install any Node version

Switch versions quickly

Set a default version

Use different versions per project

Test your app in various Node environments



🟦 1. Install NVM on Windows


Windows does not support the original nvm-sh.

Instead, we use a dedicated tool called nvm-windows.


✅ Step 1 — Download Installer

Go to: 🔗 https://github.com/coreybutler/nvm-windows/releases

Download the file: nvm-setup.exe

✅ Step 2 — Run Installer

During installation:

Choose location for NVM

Choose Node.js symlink path

Click Next → Install

✅ Step 3 — Verify Installation


Open cmd or PowerShell: nvm version


If you see a version number, NVM is ready.

✅ Install Node.js using Windows NVM


Install latest LTS: nvm install lts

Install a specific version: nvm install 18.17.0

Use a Node version: nvm use 18.17.0

Check current version: node -v

✅ 2. Install NVM on macOS (Official NVM)


On macOS, we use the original NVM from nvm-sh.


✅ Step 1 — Install via cURL

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

✅ Step 2 — Add NVM to your shell config


If you’re using zsh (default on macOS):

1echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.zshrc
2echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.zshrc


Reload config: source ~/.zshrc


✅ Step 3 — Verify NVM

nvm -v

✅ Install Node.js on macOS

Install latest Node LTS: nvm install --lts

Install specific Node version: nvm install 20.10.0

Use a version: nvm use 20.10.0

✅ 3. Install NVM on Linux

Works on Ubuntu, Debian, Fedora, Arch, etc.

✅ Step 1 — Install NVM


curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash


or using wget:


wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash


✅ Step 2 — Add to shell config (.bashrc or .zshrc)


export NVM_DIR="$HOME/.nvm"

[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"


Reload: source ~/.bashrc


✅ Step 3 — Verify


nvm -v

🎯 Common NVM Commands (macOS & Linux)


✅ List installed Node versions


nvm ls


✅ List all available versions


nvm ls-remote


✅ Set default Node version


nvm alias default 18


✅ Uninstall a Node version


nvm uninstall 16

🎯 Common NVM Commands (Windows)

List installed versions: nvm list

Set default version: nvm use 20

Uninstall version: nvm uninstall 16.0.0

🧠 Tip: Use .nvmrc File Per Project

Inside any project, create a file named: .nvmrc

Add the Node version: 18

Then run: nvm use


NVM will automatically switch to the required Node version.


Need a fast project partner? Let’s chat on WhatsApp.
Hire me on WhatsApp