Introduction

Recently, many people have asked how to install multiple versions of node at the same time? How to configure the environment variables of node, how to switch nodes in multiple versions freely? There is also the version of node when you are doing appium automation. Too high or too low to use the command to start appium and report an error, try to install a high version and a lower version of the node in a system, if you need a higher version of the switch to the higher version of the node, if you need a lower version Switching the lower version of node, this problem will be solved perfectly, for this reason, so Hong Ge intends to write an article to explain how to install multiple versions of node!!!

Node download

The node version can be  downloaded from the 
node network

or downloaded here 
https://nodejs.org/dist/

After downloading, I got the installation package. There are 32-bit and 64-bit multi-version installation packages. Users choose according to their own system.

how_to_install_multiple_versions_of_node_0.png

Installation Precautions

When installing multiple versions of node, you must install it from a low version. If you install a high version first, there will be many problems. If you have already installed it, first uninstall it and then perform the following steps.

Uninstall node

Because Hongge has installed the latest high-level node before, in order to avoid unnecessary trouble, Hongge decided to uninstall it first, then install the lower version of node, and finally install the higher version of node again.

1. After you install this software, the software has an uninstall program. You just click: Start—Program—Find this program—-There will be the uninstall program for this program.

 

2. It is uninstalled by “uninstaller”. This program is generally WINDOS, you will bring this program yourself, you point: Start–Control Panel—Uninstaller—-Find the program to be uninstalled— “Uninstall” is OK.

 

Find node and click “Uninstall”

Uninstallation completed

1. View the installation file in the installation directory and delete it completely.

2.node -v command to view the version of node

how_to_install_multiple_versions_of_node_6.png

 

3.where node command check

how_to_install_multiple_versions_of_node_7.png

 

Either of the above methods proves that node has been successfully uninstalled from your computer, you can safely install a lower version of node.

Install the node step

1. Before installing node, I first choose a node installation directory, I want to install it under the D drive, so I created a node directory in the D drive, and created a 6.9.4 folder inside, because I will install the 6.9.4 version of node in this folder.

 

2. Start the installation: Open the downloaded installation package of node6.9.4, and click Next until the installation path appears:

how_to_install_multiple_versions_of_node_9.png

how_to_install_multiple_versions_of_node_10.png

The installation path changes the path of the 4.42 folder we created, and then the next step, after the installation is successful, there are many files in the folder. At this time, the node is installed.

how_to_install_multiple_versions_of_node_11.png

Change the path inside to  D:\NODE\6.9.4\

 

After the node is installed, can it be used? Of course not, you also need to configure the environment variable, or the old method that Macro said: Computer => Properties => Advanced System Settings => Environment Variables Configure the node environment variable yourself it is good.

Click New in the system variable, the variable name: node_6.9.4, the variable value is the installation directory of your 6.9.4 version, which is D:\nNODE\6.9.4\

Click OK and find the path variable in the system variable. After selecting it, click Edit.

how_to_install_multiple_versions_of_node_17.png

See the value in the path variable? We added the newly created variable to this, how to add it? A pair of %, write the newly created variable in the middle, and then put it ( %node_6.9.4% ) To the end of the path, you must not forget the middle ; number, there should be one in the middle of each variable ;

how_to_install_multiple_versions_of_node_19.png

After setting it, click OK, then let’s open CMD (win+R); enter:  node – v

 

If the version number appears, then our first node has been installed and can be used normally;

Install multiple versions: install the second node version after the first one is installed;

Before installing the new version, all we need to do is to find the installation directory of the previous version, which is D:\NODE\6.9.4, and then rename the folder 6.9.4 to him (because if you don’t If you change the name, when you install the new version, no matter where you install it, you will overwrite the previous one):

After modifying, create a new directory, I named him 12.0.0 (because I plan to install the 12.0.0 version next time), because the latest is about 13 now, so Hongge plans to install a 12

Next, start installing 12.0.0, or the same as the low version installation process above, until our environment variable is configured, our 12.0.0 will be installed.

After installing the 12.0.0 version, let’s come back and change the directory of 6.9.4.

Verify the installed node

Verify that we are currently installing two versions of node: where node , and the version currently in use: node -v

Where node

 

Where node appears two, indicating that we are actually installing two versions of node, node -v tells us which version is currently used!!!

If we still have to install other versions, the method is the same, just follow the above.

How to switch multiple node versions

If we have a lot of nodes installed now, but the current node version is not what I want to use now? How to switch the node version?

1. Open the environment variable and find the path. Which version of the node you want to use, put the node variable at the top of all node variables, for example, my previous path is %node_4.42%; %node_5.11%, I use Is the version of 4.42, if I want to

With the 12.0.0 version, I have to change the %node_6.9.4%;%node_12.0.0% in the path to %node_12.0.0%; %node_6.9.4%

how_to_install_multiple_versions_of_node_26.png

2 At this time we will look again:  where node and node -v

 

This is the version switch between our installation of multiple versions of node and node;

summary

1. I will kill the previous version, I don’t know if the installation process is not clear. When I install the second node, I automatically create the last installed directory, which will overwrite the previous node and get rid of it. the goal of.

how_to_install_multiple_versions_of_node_28.png

2. Regarding the version switch, here, the macro brother gives you a simple method, Windows10 system, directly select the variable, through the “upward” or “down” on the right side.

how_to_install_multiple_versions_of_node_29.png

3. To learn and use, you can install multiple nodes according to the method of Hong Ge. It is enough to install two of them here. Interested, time-small partners or children’s shoes can be practiced.

Orignal link:https://www.cnblogs.com/du-hong/p/11417883.html