We have introduced cnpmjs.org and the recently launched Taobao before npm Two NPM images. In addition, there are some foreign NPM images. The speed of accessing different mirrors in different regions may be different, and each mirror may have a small number of packages that are temporarily out of sync. Therefore, sometimes it is necessary to switch NPM mirrors. Compared with manually specifying the corresponding parameters every time you switch, using nrm is much more convenient.
nrm is an NPM source manager that allows you to quickly switch between the following NPM sources:
npm
cnpm
strongloop
european
australia
nodejitsu
taobao
; npm install -g nrm
; nrm ls * npm ---- https://registry.npmjs.org/ cnpm --- http://r.cnpmjs.org/ taobao - http://registry.npm.taobao.org/ eu ----- http://registry.npmjs.eu/ au ----- http://registry.npmjs.org.au/ sl ----- http://npm.strongloop.com/ nj ----- https://registry.nodejitsu.com/
The one with *
is the source currently used. The above output indicates that the current source is the official source.
Switch to taobao
; nrm use taobao Registry has been set to: http://registry.npm.taobao.org/
You can add customized sources, especially suitable for adding private sources within the enterprise. Private sources can be built using cnpmjs.
nrm add <registry> <url> [home]
nrm del <registry>
You can also test the response time of the corresponding source through nrm test
.
For example, test the response time of the official source:
; nrm test npm npm ---- 1328ms
Test the response time of all sources:
; nrm test npm ---- 891ms cnpm --- 1213ms* taobao - 460ms eu ----- 3859ms au ----- 1073ms sl ----- 4150ms nj ----- 8008ms
Note that in order to obtain more accurate results, you can consider multiple tests take the average.
nrm is open source software licensed under the MIT license.
The above is the detailed content of How to quickly switch NPM sources. For more information, please follow other related articles on the PHP Chinese website!