前言:
由于npm包不是国内出的,所以下载东西比较慢,就要切换镜像源
1、镜像源链接切换
// 查看正在使用的镜像源:
npm config get registry | yarn config get registry
// 切换淘宝镜像源
npm config set registry https://registry.npmmirror.com/
2、nrm管理镜像源
nrm是npm的镜像源管理工具,上面是利用网址切换镜像源,比较麻烦,这里我们利用nrm方便切换镜像源
下载并全局安装nrm:
npm install nrm -g
查看可切换的镜像源:(* 表示正在使用的镜像源)
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/
3、通过nrm切换镜像源
// 切换为淘宝镜像源:
nrm use taobao
// 表示成功切换为淘宝镜像源
The registry has been changed to 'taobao'.