npm 源管理 nrm

来源:互联网 发布:比较好的程序员论坛 编辑:程序博客网 时间:2024/05/20 04:14

npm 有许多镜像,不同地区访问不同的镜像速度可能有差异,然后各个镜像各自都可能有少数包暂时没有同步,因此,有时候需要切换 NPM 镜像。相比每次切换时都手动指定相应参数,使用nrm 要方便的多。
作为国内良心互联网家,taobao为国内互联网从业人员做了一件好事,就是同步npm的镜像。大大方便了工作的需求,降低网络差造成的不爽情节。
nrm 是一个 NPM 源管理器,允许你快速地在如下 NPM 源间切换:

安装

npm install nrm -g

使用

列出可选源

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

带*号的是正在使用的源。

切换

nrm use npmRegistry has been set to: https://registry.npmjs.org/

增加源

你可以增加定制的源,特别适用于添加企业内部的私有源。私有源可以使用cnpmjs架设。

[xml] view plain copy

nrm add  <span class="tag" style="color:rgb(0,0,128)"><<span class="title" style="">registry</span>></span> <span class="tag" style="color:rgb(0,0,128)"><<span class="title" style="">url</span>></span> [home]

删除源

[xml]
nrm del <registry>

测试速度

nrm test npm

测试所有

nrm test* npm ---- 2151ms  cnpm --- 335ms  taobao - 472ms  nj ----- Fetch Error  rednpm - 194ms  npmMirror  1145ms  edunpm - Fetch Error
原创粉丝点击