报错重现
淘宝原镜像域名(registry.npm.taobao.org)的 HTTPS 证书正式到期。如果想要继续使用,需要将 npm 源切换到新的源(registry.npmmirror.com),否则就会出现如下报错。
npm ERR! request to https://registry.npm.taobao.org/xxx failed, reason: certificate has expired
解决方法
许久没有更新过版本的人,看见错误一脸懵,年前还是好好的,现在连更新依赖版本都出现报错了!其实是一个小问题。按照如下步骤进行解决:
// 1. 清空缓存
npm cache clean --force
// 2. 切换新源
npm config set registry https://registry.npmmirror.com
// 3. 查看源是否设置成功
npm config get registry
// 4. 安装或者更新
不过淘宝还是推荐它的安装方式
// 1、安装cnpm
npm install -g cnpm --registry=https://registry.npmmirror.com
// 2、检测是否安装成功
cnpm -v
// 3、安装你的依赖
cnpm install xxxxx
其他镜像
腾讯镜像
http://mirrors.cloud.tencent.com/npm/
华为镜像
https://mirrors.huaweicloud.com/repository/npm/
中科大镜像
https://registry.npmjs.org/