使用npm小技巧
2019-04-04 本文已影响0人
魔法新石

背景
使用npm经常会遇到加载某个依赖加载不了,所以需要用国内的淘宝镜像
然而,将npm改成cnpm是极不习惯的,所以看到nrm就赶紧记下来了,极是好用!
安装使用
安装nrm
npm install nrm -g --registry=https://registry.npm.taobao.org
查看镜像
nrm ls
结果如下,加星号的是当前使用的
* npm ---- https://registry.npmjs.org/
cnpm --- http://r.cnpmjs.org/
taobao - https://registry.npm.taobao.org/
nj ----- https://registry.nodejitsu.com/
使用镜像
nrm use taobao
通过命令nrm ls可以看到,镜像已经是taobao了
npm ---- https://registry.npmjs.org/
cnpm --- http://r.cnpmjs.org/
* taobao - https://registry.npm.taobao.org/
nj ----- https://registry.nodejitsu.com/
接下来就可以正常用npm安装依赖了,都很方便。