npm默认的源是国外源https://registry.npmjs.org
, 有时会很慢,可以设置淘宝源来提速
1.全局设置
查看当前源 npm config get registry
设置为淘宝源 npm config set registry https://registry.npm.taobao.org
设置其它源 npm config set registry https://registry.npmmirror.com
2.临时使用
如果只是一次性使用,可以使用
npm --registry https://registry.npm.taobao.org install XXX(模块名)
3.使用cnpm
安装cnpm npm install -g cnpm --registry=https://registry.npm.taobao.org
使用时用cnpm代替npm cnpm install XXX(模块名)
4.使用nrm
npm install -g nrm
nrm use taobao
nrm ls # 查看当前可用源命令
4.在当前项目下添加.npmrc
文件,内容如下
registry=https://nexus.shanshuiyuntu.com/repository/group-npm/