This article is borrowed from: https://lvsige.blog.csdn.net/?t=1
Need to reinstall node:
1. It was installed to C:\Program Files by default before
2. There is Chinese in the node installation path
1. If the previously installed node is under Program Files, you need to uninstall the node first, and then install it to the specified directory of the node, and there can be no Chinese in the path; eg: C:\nodejs
It is also possible on the C drive, but don’t put it under Program Files. Create a new folder on the C drive: the nodejs
path is C:\nodejs (see picture)
2. After node is successfully installed, create two folders node_global and node_cache under C:\nodejs
3. Execute the configured command
npm config set prefix "C:\nodejs\node_gobal"
npm config set cache "C:\nodejs\node_cache"
Pressing the enter key will not display the change, see the figure below
4. Configure environment variables
①: Find the environment variable in the advanced system settings
②: Find Path for system variables
③: Double-click path, click New, add C:\nodejs C:\nodejs\node_gobal C:\nodejs\node_cache to the environment variable
④: Then keep clicking OK
5. npm config ls to view the configuration information of the global installation
If the red mark below appears, the modification is ok.
6, check whether the installation is successful, you can install express to check
Command: npm i express -g
Then express -v check the version number, and it will do.
Check the node_golbal folder,
there will be a node_modules package, which contains the express we just installed.
7. Install Taobao mirror
指令:npm install -g cnpm --registry=https://registry.npm.taobao.org
Cnpm appears in node_global.