Things usually start with maintaining old and new projects on the local computer, but old projects may require older versions of Node, so it would be nice to be able to switch node versions at any time! NVM came into being.

Because I am more cautious, install NVM before looking for some other people to step on the pit, pit or some. When I felt everything was ready (I had read several articles on installing trampling pits), I started:

Operating system: Win10-64bit, Windows NVM is NVM-Windows

Step 1 (very important) :

If Node has never been installed, skip this step

Completely (always completely) uninstall node on the machine and remove NPM related directories (see stackOverflow for solutions)

A little translation (my operation) is:

  1. To kill the node process, right click on the menu bar to open task Manager, find the Node process and “End the Task”.
  2. Uninstall Node on the application management page
  3. Remove the relevant folder (if one exists) from step 4 above
  4. Delete node and NPM related environment variables
  5. In the CMD runningwhere nodeYou can see if the node has been uninstalled (if not, you will see an installation path)

Step 2:

Official website: github.com/coreybutler…

Click download installation package, I installed 1.1.8, in the Release interface to find the installation package to download

Step 3:

Nvm-setup, which is the normal software installation method, does not need to change the address (I chose the following address), and two environment variables are automatically added after the installation

Open the NVM installation directory, the default directory should be: C:\Users{user}\AppData\Roaming\ NVM \

Modify settings. TXT file, change NPM image to Taobao image, this is my configuration, default root and path do not need to change, add the next two lines

root: C:\Users\PARATERA\AppData\Roaming\nvm
path: C:\Users\PARATERA\AppData\Roaming\nodejs

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

Step four:

To perform the operation, run the following command

NVM -v: checks whether the NVM is successfully installed

NVM Arch: Shows whether node is running in 32-bit or 64-bit mode

NVM install [version]: Install node of the corresponding version, for example, NVM install v16.5.0. After the installation, you can see that the NVM directory contains the corresponding folder. To install the latest version, run the NVM install latest command

NVM ls: Lists the installed versions of Node.js

NVM use [version number] : use the installed node16.5.0 version, there is no global node or NPM variable before the version is specified successfully, do not try

After the version switchover succeeds

Node -v: view the current node version

NPM -v: Displays the current NPM version

Pit:

NVM use [version number] error:

Solution: Open CMD as an administrator, and start again

Now Using node vXXXX Now using node vXXXX Now using node vXXXX Now using node vXXXX

Have fun!

But!!! Used in a certain versionnpm i -g [package]The installed global package can be used only in the corresponding version

Such as: