Chinese path is not allowed in the following installation steps, not allowed, not allowed! ! !
1. Download Node.js
1. Enter http://nodejs.cn/ in the address bar of the browser to enter the Chinese website of node.js, or enter the Chinese website of Node in the search box and click to enter.
2. Click the download button.
3. As shown in the figure below: (Choose the type that matches your own computer, the red arrow part is the respondent's own computer type)
4. After downloading, the browser will remind you in the lower left corner of "This type of file may harm your computer. Do you still want to keep...? Click Keep." As shown below:
5. In installing node.js, just click next (but remember to change the default storage path, under normal circumstances, we install the Node.js environment, the program will automatically set the path of the NPM global module in the system disk (usually C Disk), we do not recommend setting the global path in the system disk during the project development phase, which will not only affect the performance of the computer, but also is very unsafe. It is recommended to install in the root directory of the D drive, not the C drive, if you install it in the C drive Reinstall the system in the future will be lost).
Two, start to modify the npm global installation path
1. First enter the window + r command on the page, then enter the cmd command and click OK to run the "Command Prompt" window.
2. Enter the command to view the current configuration:
npm config ls
If it is the first time to use the NPM installation package, you will only see the prefix option in the configuration, which is the default global installation directory of NPM. But if you use the NPM installation package multiple times, you will see two paths, cache and prefix, as shown below:
3. Create two new folders in the file D:\nodejs (this is the path of the answerer's own, where you just installed the two folders where you just installed) file, named node_cache and node_global respectively. As shown below:
4. Go back to the black window of "Command Prompt" and execute the following two commands:
npm config set prefix "E:\node.js\node_global"
npm config set cache "E:\node.js\node_cache"
The prefix and cache are followed by the path of your own folder. Do not reverse the order.
After the execution is successful, you can use the npm config ls command to view the configuration results.
5. Then enter the command npm install -g cnpm --registry=https://registry.npm.taobao.org in the "command prompt window".
This command code means to use Taobao NPM mirror
Then modify the npm Taobao data source
npm config set registry https://registry.npm.taobao.org
It is very slow to use the official image of npm directly in China. Taobao NPM image is recommended here.
Taobao NPM mirror is a complete npmjs.org mirror. You can use this instead of the official version (read-only). The synchronization frequency is currently every 10 minutes to ensure that it is synchronized with the official service as much as possible (here manually like Ali).
After installation, you can use the cnpm command to install the module:
For example:
$ cnpm install [name]