Introduction
Before starting with Node Version Manager, aka NVM, a BIG THANKS to Corey Butler and Team, who made this cool product possible for Windows users. This tool can only be used on Mac and Linux machines. This tool is extended for Windows machines with a lot of effort and contribution from the community. Kudos to them.
Now lets get into the basics :). NVM is a tool that allows you to download and install multiple node versions and isolate the projects and packages without affecting their functionality. This way, installing or uninstalling a particular node version will not disrupt the packages and runtime. This article contains installation instructions for Windows 10. The same steps can be performed on Windows 11 as well.
Why NVM?
When working with SPFx, you may get into a situation where the solution needs to be tested in the Node LTS version (Long Term Support). Imagine you have developed an SPFx solution using node six and deployed the package in production. Now you are on node 10. You need to implement an enhancement for the solution developed in Node 6. There are two ways to achieve it; the harder way and the smarter way.
The harder way is to uninstall the current node version (which is 10 in this case), install the node version 6, develop the enhancement build, and package it. In this case, if you want to move to the latest version of the node, you need to again uninstall the legacy and install the latest version. Switching between node versions is a bit cumbersome and manually requires uninstalling / Installing to switch back to the required node version.
The smarter way is to install the NVM (Node Version Manager). This tool, when installed on your machine, will switch to the required node version with a simple one-liner command. How cool is it? 😊
This tool manages all legacy and newer node versions independently and manages the runtime for you on the fly.

As you see in the above picture, NVM can maintain multiple versions of nodes in the same environment/machine. Each version of a node can have its node runtime, tools, and generators.
Steps to install NVM
Installing NVM on Windows 10 is straightforward. All you need to do is download the MSI package and install it. Before installing NVM, validate that no previous version of NVM has been installed.

The screenshot shows NVM is not recognized as an internal or external command.
Step 1. Go to the below link and get the latest version of NVM (Node Version Manager)
Step 2. In the resulting folder, go to the assets section and click on the nvm-setup.zip file.

Step 3. Download the file and unzip it. Right click on the installation file and select ‘Run as Administrator’. Please note that local admin rights or privileged admin rights are required to complete the proper setup.

Step 4. Select ‘I accept’ and click ‘Next’.

Step 5. You can either change the location of the folder or change it to your required one.

In some cases, the node installers may not have elevated rights to the default location, which is c:\users\username\AppData\Roaming\nvm. In this case, i have changed to c:\install\nvm

Step 6. In the next window, it will ask for the location of the symlink that needs to be created for node.js. Symlink stands for symbolic link, which is used to load the required node modules for your project during the runtime.

In some cases, the nvm may not have access to the default folder path to create packages, in this case c:\Program Files \nodejs.

Step 7. Finally, click on ‘Install’, and that will finish the installation of NVM on Windows 10.

Validation
After the installation of NVM, simply open the command prompt and type nvm.

Now you should see it. It will say the version it is running and also gives some helpful commands to get started.

Validation
To validate the successful installation of nvm, I have tried to run the following steps.
Step 1. Run the version command to get the version
nvm version

Step 2. Try installing a specific node version. In this case, I tried to install the node version v14.15.0 as this is the version supported by the SharePoint framework (at the time of writing this blog).
nvm install 14.15.0

When you see the message 'Installation complete' it confirms that the installation of the node version is completed successfully.













Vinay AyinapurapuPosted Apr 25, 2022, 4:38 AM
Thank you for taking time to read Swesh..
Swesh SPosted Apr 22, 2022, 11:37 AM
Well detailed article for nvm!!