nrm 快速切换 npm 源

由于众所周知的原因,npm官方源在国外,国外的服务器普遍网速度慢,延时大,有时候还不能响应,当然我们可以使用代理服务器,代理服务器有时候也会慢(你懂得),还有一个方法就是用国内的镜像服务器如cnpmjs.org和淘宝npm,最近发现了神器nrm,字母r和m靠的比较紧,请注意,该神器可以快速切换源,还能测速,暂时支持下面几个源:

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/

# nrm use cnpm  //switch registry to cnpm

    Registry has been set to: http://r.cnpmjs.org/

测速

# nrm test

* npm ---- 2946ms
  cnpm --- 1650ms
  taobao - 725ms
  eu ----- 1898ms
  au ----- 1552ms
  sl ----- 2124ms
  nj ----- 3243ms

使用帮助

# nrm -h

  Usage: nrm [options] [command]

  Commands:

    ls                     list all the registries
    use <registry>         change registry to registry
    add <registry> <url> [home] add one custom registry
    del <registry>         delete one custom registry
    home <registry> [browser] open the homepage of registry with optional browser
    test [registry]        show response time for specific or all registries
    help                   print this help

  Options:

    -h, --help     output usage information
    -V, --version  output the version number

项目主页:https://github.com/Pana/nrm