1, the preface


Note: This tutorial is for Windows only and may not be available for Mac

In everyday development, you might run into a situation where you have several projects, each with different needs, and each project must rely on a different version of Node.js. Without a tool in place, this can be a very difficult problem. So NVM came into being.

2. Install the NVM


1. Uninstall the installed Node. js. After the uninstallation is complete, check environment variables and remove node.js if there is any node.js left in the system.

NVM download url: https://github.com/coreybutler/nvm-windows/releases

2, Go to the NVM download address, download the NVM-setup installation package,

3, after downloading, decompress, run the installation file, installation path do not have Chinese, space, etc., do not put in C disk, may be unable to access the situation.

4, open CMD, enter NVM, and the following words will appear

5, configure the download image, innvmFound in the installation directorysetting.txtOpen the file and add the following information

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

The increase is as follows

The first line is the NVM installation path, the second line is the nodeJS path, the third line is the node download image, and the fourth line is the NPM download imageCopy the code

3. Use of NVM


Find CMD and open it in administrator mode

1. Install the specified Node.js version

nvm install 14.16
Copy the code

2, after the installation is complete, it needs to be used to take effect

nvm use 14.16
Copy the code

3. View the installed version of Node.js. The one marked with * is the one in use

nvm ls
Copy the code

4. error handling


Node.js is denied access

Solution: Uninstall NVM, check whether there are Node.js residues, including environment variables, restart, and reinstall NVM


NPM -v: NPM is not an internal or external command

This is because the NPM of node.js version 8.11 and later cannot be installed automatically. You need to install the NPM of the corresponding version manually.

NPM each version download address: https://npm.taobao.org/mirrors/npm

After downloading, unzip the file, change the name of the folder to NPM, and put it into the node_modules folder of the corresponding node.js folder in the NVM installation directory. Then, find the bin folder, copy and paste the 4 files in the following figure into the directory of node_modules

So far, solved.

5. Change the default NPM mirror source

Example Change the NPM image source to Taobao image

npm config set registry https://registry.npm.taobao.org
Copy the code

Check whether it is successful

npm config get registry
Copy the code

Or directly install Taobao image (command as follows, use is CNPM)

npm i -g cnpm --registry=https://registry.npm.taobao.org
Copy the code

6, WIN10: CNPM error


1. Find Windows PowerShell in the Start menu and run it as an administrator

2, Enter the set-executionPolicy remotesunet and enter

3. Enter againget-ExecutionPolicy, enter, show upRemoteSignedIs the success

If you think it is helpful, I am @pengduo, welcome to like and follow the comments; END

The articles

  • Micro channel small program custom Tabbar, attached detailed source code
  • Enumerative JS practical and powerful operator & operator
  • Wechat small program to achieve search keyword highlighting
  • Request encapsulation of wechat applets
  • The use of try and catch in javaScript and breaking out of forEach loops

Personal home page

  • CSDN
  • GitHub
  • Jane’s book
  • Blog garden
  • The Denver nuggets