Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
/ nvm-session Public archive

Wrapper for NVM for Windows that allows multiple GitBash windows and tabs to use different node versions

License

Notifications You must be signed in to change notification settings

davfive/nvm-session

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

Important

⛔ This project is no longer maintained ⛔

We have entered a universe where the Volta project exists
It offers everything nvm-session was trying to accomplish and much more.
I happily surrender and join the winning side.

nvm-session

Wrapper for NVM for Windows that allows multiple GitBash windows or tabs to use different node versions.

This bash function allows individual GitBash terminal windows to use their own node versions. This key feature of the real nvm (for Mac/Linux/WSL) is missing in NVM for Windows.

Usage

In your .bashrc file, add

. <path-to-nvm-session-repo>/nvm-session.sh

Then, in a GitBash terminal window, do

nvm-session use <installed-node-version>  # e.g., nvm-session use 12.16.2

Other uses:

nvm-session use <version>    : Switch to the specified version
nvm-session use              : Show installed versions (same as list)
nvm-session list|ls          : Shows installed versions and which is active
nvm-session <other-nvm-cmd>  : Calls nvm to run command

Requires

Known Limitations

  • When you enter a GitBash terminal session, the nvm's global node version will be available. No default is set.
  • cmd.exe windows not supported. Could be supported via batch script/powershell, I don't need it (yet).

How It Works

NVM for Windows magic is that it installs each of the requested node versions into $APPDATA/Roaming/nvm/v$VERSION

When you do a nvm use 12.16.2 or somthing, NVM for Windows creates a symlink at C:\Program Files\nodejs to the selected version. This creates a globally accessible node version (from cmd.exe or gitbash).

This script leverages the fact that every versioned node directory is a clean, standalone, and more importantly, usable version of node.

By prepended the path to the requested version of node to terminal's PATH variable, that terminal session becomes independent of the globally set nvm/node version, allowing us to have different versions of node in each terminal session.

The nvm on and nvm off global actions do not affect this, it'll work with it on or off.

About

Wrapper for NVM for Windows that allows multiple GitBash windows and tabs to use different node versions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages