Home  >  Article  >  Web Front-end  >  How to quickly switch NPM sources

How to quickly switch NPM sources

一个新手
一个新手Original
2017-10-11 09:59:531389browse

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

Installation

; npm install -g nrm

Use

List optional sources

; 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

Switch to taobao

; nrm use taobao                                                                                                                             

   Registry has been set to: http://registry.npm.taobao.org/

Add source

You can add customized sources, especially suitable for adding private sources within the enterprise. Private sources can be built using cnpmjs.

nrm add    [home]

Delete source

nrm del 

Test speed

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.

License

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn