npm install 报错request to https://registry.npm.taobao.org failed, reason certific

3,612 阅读1分钟

使用

npm install

报错显示

request to https://registry.npm.taobao.org/s failed, reason: certificate has expired

错误提示已经告诉原因是淘宝镜像过期了!

其实,早在 2021 年,淘宝就发文称,npm 淘宝镜像已经从 registry.npm.taobao.org 切换到了 registry.npmmirror.com。旧域名也将于 2022 年 5 月 31 日停止服务

解决方法

1、查看当前的npm镜像设置:npm config list

2、删除镜像设置 npm config delete registry

3、清空缓存 npm cache clean --force

4、设置npm镜像

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

5、查看当前的npm镜像设置:npm config list

npm源切换为官方

npm config set registry=https://registry.npmjs.org