Reference: http://www.tuicool.com/articles/nYjqeu
Reference: http://www.jianshu.com/p/0deb70e6f395
Reference: http://yijiebuyi.com/blog/b12eac891cdc5f0dff127ae18dc386d4.html
Overview
npm is the official package management tool of nodejs, on which you can download various third-party packages, which are often used in projects. However, the official download source is outside the wall, the download speed is very slow, and it often times out and fails. So we need to replace a faster download source, generally choose Taobao source in China.
Modify the source
Modify the source (temporary)
npm --registry https://registry.npm.taobao.org install express
set source (long term)
npm config set registry https://registry.npm.taobao.org
Note: It is said that this method will fail after restarting the computer. I have not tried it.
Modify configuration files (long term)
vim ~/.npmrc //Open the configuration file registry =https://registry.npm.taobao.org //Write the configuration file
cnpm
cnpm is an npm mirroring tool from Taobao that supports publishing LAN modules. The usage method is the same as npm, except that the command becomes cnpm. Official website: https://npm.taobao.org/
npm install -g cnpm --registry=https://registry.npm.taobao.org
NRM
Overview
Install
npm install -g nrm
It is recommended to install nrm after replacing the source as above, otherwise it will take a long time, or
npm install -g nrm --registry https://registry.npm.taobao.org