使用npm装些东西 结果报错了
npm报错:request to https://registry.npm.taobao.org/webpack failed, reason: certificate has expired
一、报错原因:
主要就是提示淘宝镜像过期了
二、错误提示已经说出原因是淘宝镜像过期了!
其实,早在 2021 年,淘宝就发文称,npm 淘宝镜像已经从 registry.npm.taobao.org 切换到了 registry.npmmirror.com。旧域名也将于 2022 年 5 月 31 日停止服务(到后来HTTPS证书到期后就不能用了)
三,解决方案
1、查看当前的npm镜像设置:npm config list
2,清空缓存:npm cache clean --force
3,修改npm镜像
npm config set registry https://registry.npmjs.org/ (或npm config delete registry)
注意:这里改为用npm本身的镜像,一般国内用户还是建议使用淘宝镜像,所以推荐设置成用淘宝镜像,执行:npm config set registry https://registry.npmmirror.com
4,在运行 npm config list
可以看到已经改为最新的地址了
再次运行 npm i
能看到正常使用了