preface

  • A historical issue, I used to install environment is not good, all depends on the mood, let alone do node version management.
  • I’m an old lazy dog myself, and I’ve been ignoring it. Recently, I bought a new computer. I thought I could start all over again, but my computer was ruined (yes, I bought shadow Elf 7P).
  • Mom duck got something these days, which needs my Node version to be 14 or above. According to my past urine nature, I usually upgrade to Vans. Then I don’t know that I will use different Node versions later, so I just use NVM management, and by the way, clean up the computer
  • Windows and

Uninstall the node

  1. Control panel programs programs and functionsFind NodeJs and right-click to uninstall it
  2. Restart the computer ~
  3. Find the following possible directories and delete them
    • C:\Program Files (x86)\Nodejs
    • C:\Program Files\Nodejs
    • C:\Users{User}\AppData\ folder \ NPM (or % AppData %\ NPM)
    • C:\Users{User}\AppData\Roaming\npm-cache (or % AppData % npm-cache)
  4. The last two directories above can not be deleted, generally we installed in the global package inside, can be modified by NPM global installation path
  5. checkEnvironment variable %path%Does NodeJs or NPM exist in it
  6. Command line inputwhere nodeSee if there is a directory, if there is to delete it
  7. Restart the computer ~

The use of NVM

  • Without further ado, Runoob has a tutorial.

Download address

  • nvm-windowsIf you want to install it, download itsetupthe

Fix slow downloads

  • It is usually slow to download and install Node directly
  • At this point we just need to open the NVM installation directory\nvm\setting.txtAdd the following to use Taobao source
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
Copy the code

Common NVM commands

  1. nvm install <version>– Install the specified node version
  2. nvm uninstall <version>– Uninstalls the specified node version
  3. nvm use [version] [arch]– Arch switches to 32/64 bits using the specified node version
  4. nvm ls– View the downloaded Node version
  5. nvm ls available– View all node versions online
  6. nvm -h– In fact, you can help by typing, but learn how to check his commands

Change the global installation path of NPM

  • One problem with NVM is that the packages installed globally for different versions of Node are in different versions of Node directories
  • This makes it impossible for us to share the global package after we switch the Node version, so I have to download and copy again, which is troublesome and takes up space, and is not in accordance with the style of the program ape
  1. Create two new files in your favorite directory
    • I just love being thereC:\Users\{User}\AppData\RoamingHere. This is all you want
    • One file is called NPM
    • A file is called npm-cache
    • For spicy, I have obsessive-compulsive disorder, his original node is what I like
  2. CMD runs commands to modify paths
npm config set prefix "C:\Users\{User}\AppData\Roaming\npm"
npm config set cache "C:\Users\{User}\AppData\Roaming\npm-cache"
Copy the code
  1. A crucial stepEnvironment variable %path%Add a value insideC:\Users\{User}\AppData\Roaming\npmIs the same as the previous path
  2. Remember to restart CMD!!
  3. And not only because of NVM use, you feel that the C disk is not enough to throw to other disks can also be ao ~

The last

No hot ~ can not think of the conclusion ~886886