Preface
I believe that many people will need to use different node
versions for multiple projects . If you uninstall and install each time, node
it will be very troublesome to manage the version by yourself . By using nvm
it, we can solve node
the problem of switching between multiple versions . This article contains common Pit and solution, I hope to help you, nvm
the other download address is https://github.com/coreybutler/nvm-windows/releases , if the download is too slow, I also provide the 1.1.7 version at the end of the article milk.
installation
After downloading the compressed package, double-click to run, and after accepting the agreement, the following interface will appear:
Here you can set nvm
the installation location, here I set it D:\nvm
, and then click next
, the following interface will appear:
What needs to be set here is nodejs
the installation location, here we need to pay special attention: nodejs
the installation path must be within nvm
the installation path , otherwise it will not be available later node
, because we set nvm
the installation location to D:\nvm
, here we set nodejs
the installation location Set the order D:\nvm\nodejs
, and then click next
and then click install
to install.
note
After installation, we need to confirm nvm
the environment variables NVM_HOME
and NVM_SYMLINK
whether they are properly set up. You can cmd
enter the following command to confirm:
echo %NVM_HOME%
echo %NVM_SYMLINK%
If you get the results normally (the folder path is printed), you can ignore the next step. If the file path does not appear, you need to add these two variables to the environment variables, NVM_HOME
and the sum NVM_SYMLINK
corresponds to the setting in the installation above Two positions.
downloadnode
Before downloading, in order to improve node
the download speed, we need to set the domestic mirror download address first. We first need to find nvm
the location of the folder, and then choose settings.txt
to modify it:
Then add the following configuration to the file:
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
After saving, we can start node
the download, first open it cmd
, and then enter it nvm install version
to download the specified version, here is 8.9.1 as an example, we enter nvm install 8.9.1
, after a while, the following content will appear, I also downloaded 12.18 The .4 version is not shown here:
Then we nvm ls
can view the node
list of currently available versions through:
Then we nvm use 8.9.1
can use the version by passing, and then passing node -v
and npm -v
confirming node
and npm
all can be used normally:
nvm use 8.9.1
node -v
npm -v
Modify the npm
installation package location
Since the npm
default download and installation location is on the C drive, we may want to modify the download location. We first enter the following command in the command line:
npm config ls
Then you can find the location of the configuration file:
Then we find .npmrc
the location according to the displayed path , then open it with Notepad and modify it to the location we want to store:
prefix=D:\nvm\nodejs\lib
cache=D:\nvm\nodejs\cache
to sum up
This article briefly introduces the nvm
usage and configuration methods. If you encounter some problems during the installation, you are welcome to communicate.
Download
Link: https://pan.baidu.com/s/1UnCzPJ5v_oo-JhA-nK4_uw
Extraction code: xuwn