前言

nrm 官方介绍

nrm can help you easy and fast switch between different npm registries, now include: npm, cnpm, taobao, nj(nodejitsu). nrm 可以帮助您轻松快速地在不同的 npm 注册中心之间切换,目前包括:npm、cnpm、taobao、nj(nodejitsu)。

安装

1
npm install -g nrm

使用

查看当前源

1
2
3
4
5
6
7
8
9
10
nrm ls

* npm ---------- https://registry.npmjs.org/
yarn --------- https://registry.yarnpkg.com/
tencent ------ https://mirrors.cloud.tencent.com/npm/
cnpm --------- https://r.cnpmjs.org/
taobao ------- https://registry.npmmirror.com/
npmMirror ---- https://skimdb.npmjs.com/registry/

nrm use cnpm

查看当前源

其中带*号的是当前使用的源

1
2
3
4
5
6
7
8
nrm ls

* npm ---------- https://registry.npmjs.org/
yarn --------- https://registry.yarnpkg.com/
tencent ------ https://mirrors.cloud.tencent.com/npm/
cnpm --------- https://r.cnpmjs.org/
taobao ------- https://registry.npmmirror.com/
npmMirror ---- https://skimdb.npmjs.com/registry/

切换

1
nrm use taobao

增加

你可以增加定制的源,特别适用于添加企业内部的私有源,执行命令 nrm add ,其中 registry 为源名,url 为源的路径。

1
nrm add mytest http://xxx/repository/npm-public/

删除

执行命令 nrm del 删除对应的源。

1
nrm del mytest

测试速度

你还可以通过 nrm test 测试响应源的响应时间。

1
nrm test taobao

登录

1
2
3
4
5
6
7
nrm login <registry> [value]              Set authorize information for a registry with a base64 encoded string or username and pasword
-a --always-auth Set is always auth
-u --username <username> Your user name for this registry
-p --password <password> Your password for this registry
-e --email <email> Your email for this registry

nrm login mytest -a -u 'xx' -p 'xxx' -e 'xx@xx.com'