Method 1:
Change the npm configuration file:
npm config set registry URL
URL is the mirror site address that needs to be set, such as Taobao mirror:https://registry.npmmirror.com
Reference website:http://www.example.com/w3cnote/npm-slow-use-cnpm.html。
Method 2:
Install nrm for management. The prerequisite for installing this is to ensure that you can connect to the current mirror address:
npm install -g nrm
After installing nrm, use nrm to manage the mirror address and switch with one command, for example:
nrm use taobao
Besides the Taobao site mirror, nrm also has others. You can use the following command to view them:
nrm ls
Um, after installing npm with sudo apt-get install npm, I wanted to install nrm as well. But after installing nrm, I executed the above command and found a prompt saying the nrm command was not found -_-|| Well, it turned out I forgot to install node.
Download node, for example, download the .tar.gz archive of version 0.12.7:
Extract:
tar zxvf node-v0.12.7.tar.gz
After going into the extracted folder:
./configure --prefix=/usr/node
--prefix=/usr/node specifies the command path after installation. You can omit it and use the default, that is, just run ./configure.
Compile and install (prerequisite: having g++/gcc compilation tools):
sudo make && make install
npm ---- https://registry.npmjs.org/ cnpm --- http://r.cnpmjs.org/ * taobao - https://registry.npmmirror.com edunpm - http://registry.enpmjs.org/ eu ----- http://registry.npmjs.eu/ au ----- http://registry.npmjs.org.au/ sl ----- http://npm.strongloop.com/ nj ----- https://registry.nodejitsu.com/ pt ----- http://registry.npmjs.pt/
Use nrm to switch mirror addresses:
nrm use taobao
Of course, you can also add your own mirror address in nrm:
nrm add URL 'registry_name'
Or delete mirror addresses that are not needed:
nrm del 'registry_name'
nrm also provides testing of the response speed of mirror addresses:
nrm test ['registry_name']
Source address: http://blog.csdn.net/u012342408/article/details/48809097