Windows - Run multiple node versions

Windows - Run multiple node versions

·

2 min read

So you have a project that will only run/build using an old Node.js version that you can't upgrade but you also do development using the latest version. What do you do? Only build using your CI pipelines? That could work but would make the development process slow.

I've run into this problem a few times, mainly with SharePoint Framework (SPFx) solutions that only support a particular (old) node version. This is where the Node Version Manager comes in and saves us!

Node Version Manager - Simple bash script to manage multiple active node.js versions

https://github.com/nvm-sh/nvm

This allows us to have multiple Node versions installed on the same machine at the same time. We can then use a couple of console commands to switch between active versions. The main solution was built for Mac/Linux but there is a windows port available:

nvm-windows - A node.js version management utility for Windows. Ironically written in Go.

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

Installation

  • Grab the latest nvm-setup.zip file from the releases page.
  • Extract the installer to a local directory.
  • Run nvm-setup.exe
  • Click through the setup, leave the defaults.

Open up a console window and type:

nvm

You should see a list of available commands that can be executed

Install a specific version of node

In a console window:

nvm install \[version\]

  • Example (install 8.11.1): nvm install 8.11.1
  • Example (install latest stable version): nvm install latest

List installed versions

In a console window:

nvm list

Switch to a specific version

In a console window:

nvm use 8.11.1

Further instructions can be found in the GitHub repository

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