Installation and use of NVM on Windows

Time:2021-7-31

Installation and use of NVM on Windows

background

When we develop or maintain projects, due to historical reasons, different projects usenodeThe versions of are inconsistent, which undoubtedly adds difficulties to our development and maintenance. In order to solve this problem, the node version manager came into beingnvm, it isnodeVersion management is convenient to install different versions of on your computer or virtual machinenodeDevelopment and maintenance, well reduce the cost.

preparation

If you installednodeIf so, please uninstall the relevant content completely. If it has not been installed, ignore this item

1. Execute the NPM cache clean — force command to clear all cache files in the cache directory
2. Computer uninstaller uninstalling node
3. Find the following directory to find the contents of relevant node / NPM. Once found, delete the relevant directory

  • C:\Program Files (x86)\Nodejs
  • C:\Program Files\Nodejs
  • C: \ users {user} \ appdata \ roaming \ NPM (or% appdata% \ NPM)
  • C: \ users {user} \ appdata \ roaming \ NPM cache (or% appdata% \ NPM cache)
  • C: \ users {user}. Npmrc (or query with.Prefixed files)
  • C:\Users{User}\AppData\Local\Temp\npm-*

4. Delete aboutnodeandnpmEnvironment variables (user variables and system variables)
5. Restart the computer

Installation steps

nvmThe installation of is divided into Mac, Linux and windows. Here I only demonstrate the Windows version,GitHub address

Download NVM installation packagePoke me to download

Installation and use of NVM on Windows

The following explains the different resources listed. I downloaded the installation package

  • Nvm-noinstall.zip: This is a green installation free version, but it needs to be configured before use
  • Nvm-setup.zip: This is an installation package. Click Install after downloading. You can use it without configuration, which is convenient.
  • Source code (zip): zip compressed source code
  • Sourc code (tar. GZ): the source code of tar.gz, which is generally used in * Nix system

Fool installation (all the way, the installation is completed)

After installation, enternvm versionCommand. If the version you installed is displayed, the installation is successful

Installation and use of NVM on Windows

to configure

  • Modify node image address:nvm node_mirror https://npm.taobao.org/mirrors/node/
  • Modify NPM image address:nvm npm_mirror https://npm.taobao.org/mirrors/npm/

Common commands

command explain
nvm list [available] List the installed or officially available downloadable node versions
nvm install <version> Download the specified version of node. If it is latest, it means to download the latest version
nvm use <version> Use or switch node version
nvm uninstall <version> Uninstall the installed version of node
nvm version View current NVM version
nvm node_mirror <node_mirror_url> Set node mirror address
nvm npm_mirror <npm_mirror_url> Set NPM image address

Example

Installation and use of NVM on Windows

This work adoptsCC agreement, reprint must indicate the author and the link to this article

Give each hair a name before it falls out~