背景

使用npm经常会遇到加载某个依赖加载不了,所以需要用国内的淘宝镜像

然而,将npm改成cnpm是极不习惯的,所以看到nrm就赶紧记下来了,极是好用!

安装使用

安装nrm

npm install nrm -g --registry=https://registry.npm.taobao.org

查看镜像

nrm ls

结果如下

1
2
3
4
5
6
7
* 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 taobao

通过命令nrm ls可以看到,镜像已经是taobao了

1
2
3
4
5
6
7
  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/

接下来就可以正常用npm安装依赖了,都很方便。