1. NVM for download

NVM is a node.js version management tool. You can use NVM to install Node and quickly switch node versions

For Windows computers, download the nVM-setup. zip installation package

Download address

nvm-download

NVM – setup. Zip (v1.1.7)

2. Common NVM commands

The command instructions
nvm list available Displays all versions of Node.js that can be installed
nvm list Displays all installed Versions of Node.js
nvm use Switch to the specified NodeJS version
nvm install Install the specified node.js version, for example, NVM install 8.12.0
nvm uninstall Uninstall the specified node.js version, for example, NVM uninstall 8.12.0
nvm on Enable node.js version management
nvm off Disabling Node.js versioning (without uninstalling anything)

3. Management of NPM

When using NVM, the default prefix is the installation path of the currently active Node.js version.

One problem is that after switching the version, the global command module installed before needs to be re-installed, which is very inconvenient.

The solution is to configure a unified global module installation path.

Create nPM_global and npM_cache folders for the global installation path and global cache path of the NPM package, respectively

NPM command to view various global paths

  • View the global installation path of the current NPM package
npm prefix -g 
Copy the code
  • View the global cache path of the current NPM package
npm config get cache
Copy the code
  • Viewing the Configuration List
npm config ls
Copy the code
  • View all information about the configuration list
npm config ls -l
Copy the code

Every time you switch node versions using NVM, it is a good idea to check whether the NPM global configuration path is invalid

NPM Command to modify the global path

  • Change the global installation path of the NPM package
npm config set prefix "E:\NodeJs\npm\npm_global"
Copy the code
  • Change the global cache location of NPM packets
npm config set cache "E:\NodeJs\npm\npm_cache"
Copy the code

Configuring environment Variables

Configure the global installation path of the NPM package in the environment variable

This computer -> Properties -> Advanced System Settings -> Environment Variables -> System Variables -> Path -> Edit -> New path -e :\ nodej\ NPM \npm_global (path can be found according to NPM prefix -g)

4. Management of yarn

  • Installation of yarn
npm install yarn -g
yarn -v
Copy the code

[Note] If installed for the first timeyarnAfter the operationyarn -vCan’t showyarnYou can restart the terminal and try again

The default path for storing the cache and package of YARN is on disk C. Therefore, you are advised to change the path after the installation

Yarn View various path commands

  • Viewing the location of yarn bin (prefix)
yarn global bin
Copy the code
  • Viewing the Yarn Global Installation Location (Folder)
yarn global dir
Copy the code
  • Viewing yarn Global Cache Location (Cache)
yarn cache dir
Copy the code
  • Viewing the Configuration List
yarn config list
Copy the code

Yarn Modify path command

  • Changing the location of yarn global bin (prefix)
yarn config set prefix "E:\NodeJs\npm\yarn_bin"
Copy the code
  • Change the yarn Global Installation Location (Folder)
yarn config  set global-folder "E:\NodeJs\npm\yarn_dir"
Copy the code
  • Changing yarn Global Cache Location (cache)
yarn config set cache-folder "E:\NodeJs\npm\npm_cache"
Copy the code

Configuring environment Variables

Add E:\ nodej\ NPM \yarn_bin to the path variable of the environment variable to determine whether there is an automatically generated bin directory in this directory. If so, add E:\ nodej\ NPM \yarn_bin