常用的npm镜像源配置方法
一、切换到淘宝镜像源
-
配置命令:
npm config set registry https://registry.npmmirror.com -
验证配置:
npm config get registry如果返回
https://registry.npmmirror.com,则说明镜像源配置成功。
二、切换到腾讯云镜像源
-
配置命令:
npm config set registry http://mirrors.cloud.tencent.com/npm/ -
验证配置:
npm config get registry如果返回
http://mirrors.cloud.tencent.com/npm/,说明镜像源配置成功。
三、切换到华为云镜像源
-
配置命令:
npm config set registry https://mirrors.huaweicloud.com/repository/npm/ -
验证配置:
npm config get registry如果返回
https://mirrors.huaweicloud.com/repository/npm/,则表示镜像源配置成功。
四、通过淘宝提供的 cnpm 工具安装包
-
安装
cnpm:npm install -g cnpm --registry=https://registry.npmmirror.com -
使用
cnpm安装依赖:cnpm install xxx