background

Node is out at version 17, but MY computer is still version 14 and I don’t want to upgrade. I didn’t want to upgrade because I had problems with Node16 when I downloaded the Vite project.

But there are some projects where node16 is already required.

At this point, NVM can be used to manage node versions.

Install the NVM

To download NVM, go to Releases · CoreyButler/NVM-Windows (github.com).

Then you can just install it with one click.

Since node has been installed on your computer before, NVM asks if you want it to control your version, and we say yes.

After the installation is complete, enter NVM and the version number appears, indicating that the installation is successful.

Enter node -v to view the version. (If the previous Node was not installed on drive C, this will cause an error, but forget it.)

Enter NVM ls to view available versions. (This is empty if Node is not installed on drive C, but don’t worry.)

Configure the NVM image

Go to the NVM installation directory to modify the image, speed up the download of C:\Users\dgbuaa\AppData\Roaming\ NVM

Copy in these two sentences:

node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
Copy the code

Download the Node version

Download node 16.13.1, NVM install 16.13.1. (It will stay there for about 10 minutes, but it is not stuck, it is downloading. Please do not close the window.)

After downloading, check the node list, NVM LS

Switching node Versions

Then switch the node version, you need to right-click the administrator to open, otherwise cannot switch, will report an error.

Then you have successfully switched node versions.

Pay attention to

If you use NPM global packages, you may not find them because they are stored in their respective node_modules versions, so you may need to install the global packages for each node version.

NPM image manager

I see there are still a lot of articles on how to configure Taobao mirror for NPM, I actually do not recommend this approach. Because the NPM package on Taobao source will do a layer of processing, sometimes using the mirror package on Taobao source cannot run in the project, you need to cut back to the NPM source to download. Therefore, I recommend using the NRM package to manage the mirror source of the NPM mirror, which is convenient when switching back and forth.

NRM download is not as troublesome as NVM, directly install NRM globally.

npm i nrm -g
Copy the code

Look at mirror

Enter NRM ls to view available NPM images.

NPM speed

Enter NRM test to view the download speed

Switch to Taobao Source

Type NRM use Taobao, which can be switched on without an administrator. In the past, there was a * indicating the NPM image currently used, but now I can’t see it. I can only see it during NRM test. I don’t know if it is my computer’s problem or the NRM version’s problem, but now IT is using taobao’s image.

Using NPM to view is also to use taobao’s image, NPM config get Registry

Adding a Mirror Source

However, we found that this URL address is different from the taobao source address recommended on the market. We can add a new source of Taobao2 by ourselves

nrm add taobao2 http://registry.npm.taobao.org/
Copy the code

So there is one more taobao2 out

Let’s measure the speed: NRM test,

Discovery is indeed a bit faster than NRM’s own Taobao source.

Deleting a Mirror Source

If one day it doesn’t work, we just delete it! NRM del taobao2, which removes the source you added.

Let’s test it again, NRM test

Example Delete the mirror source of the NRM

We found npmMirror incredibly slow! However, the NRM source cannot be deleted by using NRM del, so we need to delete it in the global configuration of NRM.

Go to the NRM installation directory: C:\Users\ [your own user name] \AppData\Roaming\ NPM \node_modules\ NRM and change registries. Json

Look at the source and it’s deleted

NVM Reference article: juejin.cn/post/701139…