Recently, I started a new personal project. The code compilation requires a lower version of node. Uninstalling the current node and reinstalling it, and then resetting the environment variables is obviously not a flexible solution. I fell into the arms of NVS .
Because I am a windows system, I will only talk about the installation and use experience in this environment.
-
Download nvs
to the NVS release page of the Github code warehouse . Each release version has corresponding Release Notes and different types of download resources Assets . I chose the latest version v.1.6.0 . Go to Assets and click nvs-1.6.0.msi , and choose to save the file in the pop-up window -
After the installation nvs download is complete, click the .msi file to complete the installation -
GitBash environment configuration
-
Create a new .bash_profile file in the user folder and add the following code
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
-
Create a new .bashrc file in the same file path and add the following code
export NVS_HOME=$LOCALAPPDATA/nvs . $NVS_HOME/nvs.sh
In my environment, $LOCALAPPDATA=C:/Users/Xiayidan/AppData/Local
- User command line (CMD) environment configuration
- To define the installation path, run the following command
for single-user installation:
During system installation:set NVS_HOME=%LOCALAPPDATA%\nvs
set NVS_HOME=%ProgramData%\nvs
- Install, run the command
"%NVS_HOME%\nvs.cmd" install
- PowerShell environment configuration
- To define the installation path, run the following command
for single-user installation:
During system installation:$env:NVS_HOME="$env:LOCALAPPDATA\nvs"
$env:NVS_HOME="$env:ProgramData\nvs"
- Install, run the command
. "$env:NVS_HOME\nvs.ps1" install
- After using nvs
to perform the above steps, you can open any shell terminal, use the nvs command line to add, delete different versions of Node, and switch at will.