nrm (Node Registry Manager) - npm 源管理工具使用

使用 nrm 来快速切换 npm 的源。

安装

1
npm i nrm -g

命令工具

列出当前的源

1
2
3
4
5
6
7
8
9
nrm ls

* npm -------- https://registry.npmjs.org/
yarn ------- https://registry.yarnpkg.com/
cnpm ------- http://r.cnpmjs.org/
taobao ----- https://registry.npm.taobao.org/
nj --------- https://registry.nodejitsu.com/
npmMirror -- https://skimdb.npmjs.com/registry/
edunpm ----- http://registry.enpmjs.org/

检查各个源的访问速度

1
2
3
4
5
6
7
8
9
nrm test

* npm ---- 1105ms
yarn --- 1106ms
cnpm --- 1734ms
taobao - 252ms
nj ----- Fetch Error
npmMirror 1459ms
edunpm - 1382ms

切换源

1
2
3
nrm use taobao

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

增加源

假设我们的私有部署如下:

源地址: http://127.0.0.1:9999/npm-all

首页: http://127.0.0.1:8888

首页地址可有可无,没有的话就空着好了。

1
2
3
nrm add localhost http://127.0.0.1:9999/npm-all http://127.0.0.1:8888

add registry localhost success

之后可以使用 nrm 来切换源:

1
nrm use localhost

删除源

1
nrm del localhost

访问源的首页

1
nrm home npm

可以打开这个源的首页,前提是这个源配置有首页。

–END–