天天看點

nrm切換npm源

在使用npm時,官方的源下載下傳npm包會比較慢,國内我們基本使用淘寶的源,最近公司内部搭建了一套npm私有倉庫。要添加自己公司内部的npm源,公司内部的源不可能把npm官方的npm包都全量同步,故需要npm源之間的切換,如果使用npm registry xxx的話,太不好管理了。nrm是管理npm源切換的利器。使用方法如下:

安裝nrm

npm install -g nrm
           

nrm --help

Usage: nrm [options] [command]


  Commands:

    ls                           list all the registries
    current                      show current registry name
    use <registry>               change registry to registry
    add <registry> <url> [home]  add one custom registry
    del|rm <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
           

主要使用ls和use指令

1)nrm ls是列出來現在已經配置好的所有的原位址

npm ---- https://registry.npmjs.org/
* cnpm --- http://r.cnpmjs.org/
  taobao - http://registry.npm.taobao.org/
  nj ----- https://registry.nodejitsu.com/
  rednpm - http://registry.mirror.cqupt.edu.cn
  npmMirror  https://skimdb.npmjs.com/registry
           

2)nrm use是切換到哪個源上

nrm use npm
           

3)nrm add添加源

4)nrm del删除源

5)nrm test測試源的響應時間,可以作為使用哪個源的參考

繼續閱讀