node.js之nrm快速切换NPM源

在使用npm时,官方的源下载npm包会比较慢,国内我们基本使用淘宝的源。但有时需要切换NPM源,如何快速切换呢? nrm帮助我们快速切换你想要的NPM源。

安装 nrm

1
npm install -g nrm

列出所有的源

1
nrm ls

实例:

1
2
3
4
5
6
7
8
9
fujinliang:didianBlog fujinliang$ 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/

选择所要用的源

1
nrm use taobao

实例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

fujinliang:didianBlog fujinliang$ nrm use taobao



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

fujinliang:didianBlog fujinliang$ 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/

更多命令

1
nrm --help
谢谢你请我吃糖果