When working with SPFx, you may get into a situation where the solution needs to be tested in Node LTS version (Long Term Support). Imagine you have developed an SPFx solution using node 6 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 2 ways to achieve it, the harder way and smarter way.SharePoint-2013-Hosting

The harder way is to uninstall the current node version (which is 10 in this case) and install node version 6 and develop the enhancement build and package it. In this case, if you want to move to the latest version of node, you need to again uninstall the legacy and install the latest version. Switching between node version is a bit cumbersome and it is required to uninstall / Install manually to switch back to required node version.

The smarter way is to install the NVM (Node Version Manager). This tool when installed on your machine, will switch to required node version with 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.

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 there is no previous version of NVM installed.

In the screenshot, it 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 and right click on the installation file and select ‘Run as Administrator’. Please note that it is required to have local admin rights or privileged admin rights to have the proper setup complete.

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. For this scenario, I left default and clicked on ‘Next’.

Step 6

In next window, it will ask for location of 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. I am leaving it as default for this scenario.

Step 7

Finally click on ‘Install’ and that finishes your 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 will say the version it is running, and also gives some helpful commands to get started.