🎯 Introduction
Different tools and projects may require specific versions of Node.js and npm. For example, if you’re building or testing npm packages, you may need to switch between multiple Node.js versions. That’s where Node Version Manager (nvm) comes in.
On Linux and macOS, developers use nvm, but on Windows, you’ll use nvm-windows — a similar tool tailored for Windows. It allows you to install, manage, and switch between different versions of Node.js and npm.
👉 In this guide, we’ll focus on nvm-windows (recommended), because it gives you the flexibility professional developers rely on. But if you just want the quickest way to try Node.js without version management, you can skip ahead to the Alternative: Official Node.js Installer section at the end.
We’ll cover:
- Installing nvm-windows
- Using it to install and switch Node.js versions
- Creating your first script
- Troubleshooting common issues
- An alternative installation method
📦 What You’ll Install
- Node.js → Run JavaScript outside the browser.
- npm (bundled with Node) → Manage and install packages.
- nvm-windows (recommended) → Manage multiple Node.js versions.
⚙️ Install with nvm-windows (Recommended)
💡 Tip: If you already installed Node.js or Yarn, uninstall them first before setting up nvm-windows. This avoids conflicts and strange errors with npm packages. Restart your PC after uninstalling, then confirm with:
node -vIt should say command not found.
Step 1: Download
Head over to the nvm-windows releases page.
- Download the latest
nvm-setup.exeinstaller.
Step 2: Install
Run the installer and follow the wizard (default options are fine).
Step 3: Verify Installation
Open Command Prompt or PowerShell (as Administrator is recommended) and run:
nvm -v
If you see a version number, congrats — nvm-windows is installed! 🎉
Step 4: Install Node.js Versions
- Install the LTS (recommended) version:
nvm install lts - Install the latest version:
nvm install latest - See all available versions:
nvm list available - Install a specific version:
nvm install 22.18.0
Step 5: Use Installed Versions
Switch between versions anytime:
nvm use lts
nvm use latest
nvm use 22.18.0
To see which ones are installed:
nvm list
Step 6: Verify Node and npm
node -v
npm -v
📝 npm comes bundled with each Node.js version. If you need a different npm version, install it separately with:
npm install -g npm@<version>
👩💻 Create Your First Script
- Create a file hello.js:
console.log("Hello from Node.js!"); - Run it in your terminal:
node hello.js
🐞 Common Issues & Fixes
nodenot recognized → Close and reopen your terminal.- Switching versions didn’t work → Run
nvm use <version>again. - Corporate proxy issues → Configure npm:
npm config set proxy http://user:pass@host:port npm config set https-proxy http://user:pass@host:port
📌 Which Version Should You Use?
- LTS (Long-Term Support) → Best for stability and most developers.
- Current → Latest features, updated frequently.
Check anytime with:
node -v
🛠️ Alternative: Official Node.js Installer
If you don’t want to use nvm-windows, you can install Node.js directly:
- Go to the Node.js download page.
- Download the latest LTS (Long Term Support) prebuilt version (recommended for beginners) for your operating system (Windows, MacOS, Linux, AIX). Alternatively we can download using nvm, fnm or Docker), which we will look into in later notes. I am using the version v22.20.0 (LTS).
- Run the installer (defaults are fine).
- Verify in a new terminal (or command prompt):
node -v npm -v
⚠️ Limitation: This method doesn’t allow you to switch between multiple versions — which is why we recommend nvm-windows.