一、修改成腾讯云镜像源
1. 设置命令
npm config set registry http://mirrors.cloud.tencent.com/npm/
2. 验证命令
npm config get registry
npm_6">如果返回 http://mirrors.cloud.tencent.com/npm/,说明镜像配置成功。
二、修改成淘宝镜像源
1. 设置命令
npm config set registry https://registry.npmmirror.com
2. 验证命令
npm config get registry
npmmirrorcom_14">如果返回 https://registry.npmmirror.com,说明镜像配置成功。
三、修改成华为云镜像源
1. 设置命令
npm config set registry https://mirrors.huaweicloud.com/repository/npm/
2. 验证命令
npm config get registry
npm_22">如果返回 https://mirrors.huaweicloud.com/repository/npm/,说明镜像配置成功。
npm_24">四、通过使用淘宝定制的cnpm安装
npm_25">1. 安装cnpm
npm install -g cnpm --registry=https://registry.npmmirror.com
npm_28">2. 使用cnpm
cnpm install xxx
将 xxx 替换为你要安装的npm包名。
// 查询源
yarn config get registry
// 更换国内源
yarn config set registry https://registry.npmmirror.com
// 恢复官方源
yarn config set registry https://registry.yarnpkg.com
// 删除注册表
yarn config delete registry