npm使用国内淘宝镜像的方法
一.通过命令配置
(1)命令 :
npm config set registry https://registry.npm.taobao.org
(2)验证命令
npm config get registry
如果返回https://registry.npm.taobao.org,说明镜像配置成功。
二、通过使用cnpm安装
(1)安装cnpm
解决安装卡顿或无法安装:
# 注册模块镜像
npm set registry https://registry.npm.taobao.org
// node-gyp 编译依赖的 node 源码镜像
npm set disturl https://npm.taobao.org/dist
// 清空缓存
npm cache clean --force
// 安装cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
(2)使用cnpm
npm run serve
cnpm install --save axios
cnpm install --save querystring
cnpm install --save vue-router