Home Coding & Scripting Setup Node.js on Windows Using nvm

Setup Node.js on Windows Using nvm

236
0

🎯 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 -v

It should say command not found.

Step 1: Download

Head over to the nvm-windows releases page.

  • Download the latest nvm-setup.exe installer.

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

  1. Create a file hello.js: console.log("Hello from Node.js!");
  2. Run it in your terminal: node hello.js

🐞 Common Issues & Fixes

  • node not 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:

  1. Go to the Node.js download page.
  2. 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).
  3. Run the installer (defaults are fine).
  4. 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.


References

Previous articleNode Version Manager (nvm): A Developer’s Guide to Installing and Managing Node.js Versions
Next articleGetting Started with Node.js: Setup and Hello World
Heartin Kanikathottu
As a seasoned Cloud and Security Architect, I’ve led transformative initiatives in key roles, including Vice President at Morgan Stanley, Principal Architect at Societe Generale, and Tech Lead & Cloud Security Architect at VMware, among others. I’m also an internationally published author with multiple books available on platforms like Amazon and O'Reilly. Notably, one of my books was recognized as the 8th best cloud computing book of all time in 2020, reflecting the impact of my contributions to the field. With over 15 professional certifications from providers such as Microsoft (Azure), Amazon (AWS), Oracle (Java), Pivotal (Spring), and IBM, I bring a wealth of expertise to my work. Academically, I hold dual Master’s degrees in Cloud Computing and Data Analytics. I’m passionate about sharing knowledge and mentoring others, which is why I actively speak at global technical forums such as Tech Opportunities Fest at Platform Calgary, Google's Kubernetes Meetup, Java User Group, Elasticsearch Meetup, and the Agile India Conference.

LEAVE A REPLY

Please enter your comment!
Please enter your name here