npm报错:request to https://registry.npm.taobao.org failed, reason certificate has

323 阅读1分钟

问题

好久没写代码,再重新写代码,安装依赖,执行npm instal,报如下错误

request to https://registry.npm.taobao.org/@sxzz%2fpopperjs-es failed, reason: certificate has expired

原因

淘宝镜像过期了,其实,早在 2021 年,淘宝就发文称,npm 淘宝镜像已经从 registry.npm.taobao.org 切换到了 registry.npmmirror.com。旧域名也将于 2022 年 5 月 31 日停止服务(不过,直到今天 HTTPS 证书到期才真正不能用了)

解决方案

切换镜像源即可

第一步:查看当前镜像设置:npm config list

第二步:清空缓存

npm cache clean --force

第三步:修改淘宝镜像为新的地址

npm config set registry https://registry.npmmirror.com

第四步:再次运行 npm config list,查看结果