How to Install NVM on Windows and Manage Node.js Versions in Git Bash

📌 Introduction

If you’re a JavaScript developer working on multiple projects, you’ll often need different versions of Node.js for each project. On Linux and macOS, nvm (Node Version Manager) is the go-to tool for this — but on Windows, the situation is a bit different.

In this post, I’ll guide you on how to:

  • Install nvm-windows
  • Set up Git Bash or Zsh for a Unix-like experience
  • Use nvm-session.sh to switch Node.js versions per terminal session — without affecting your global environment

📥 Install NVM for Windows

First, download and install nvm-windows from the official repository:

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

📌 Note: Windows has its own version of nvm that’s different from the one used on Linux/macOS.

👉 Installation Steps:

  1. Download the latest .exe installer.
  2. Run the installer and follow the setup instructions.
  3. Open a new terminal and type:
nvm version

You should see the installed NVM version.

📥 Install Git Bash or Zsh

If you prefer a Unix-like terminal experience on Windows, install Git Bash or Zsh (via WSL):

Once installed, open Git Bash or Zsh and check if it detects nvm:

nvm version

🔄 Install and Use Multiple Node.js Versions

To install Node.js versions:

nvm install 20.11.0
nvm install 20.19.0

To switch versions globally:

nvm use 20.11.0

However — here’s the catch:
this changes the Node.js version globally for all terminal sessions.

🎯 Switch Node.js Version Per Terminal Session with nvm-session.sh

To avoid changing Node.js versions globally, you can use this handy script called nvm-session.sh, which allows you to switch Node.js versions for just the current terminal session.

📥 Create nvm-session.sh

Download https://github.com/davfive/nvm-session/blob/main/nvm-session.sh

or download from this link nvm-session.7z

📌 Install nvm-session.sh in Git Bash or Zsh

Now that the script is created, we need to source it in your Bash or Zsh terminal.

For Bash (.bashrc):

Open your .bashrc file, add the following line to source the nvm-session.sh script:

. /d/code-tools/nvm-session.sh

For Zsh (.zshrc):

Open your .zshrc file, add the following line:

. /d/code-tools/nvm-session.sh

For convenience, you can create an alias for the nvm-session.sh script:

▶️ Usage of nvm-session.sh

In .bashrc or .zshrc, add:

alias nvms="nvm-session"

Then you can switch Node.js versions like this:

nvms 20.11.0

✅ Conclusion

Managing multiple Node.js versions on Windows becomes easier with nvm-windows, but combining it with Git Bash or Zsh and nvm-session.sh gives you even more flexibility — letting you switch Node.js versions per terminal session without affecting your global environment.

Scroll to Top