问题
最近使用npm下载的时候,报这个错
request to https://registry.npm.taobao.org/moment failed, reason: certificate has expired
问题是淘宝镜像过期
其实,早在 2021 年,淘宝就发文称,npm 淘宝镜像已经从 registry.npm.taobao.org 切换到了 registry.npmmirror.com。旧域名也将于 2022 年 5 月 31 日停止服务
解决方案
1、查看当前的npm镜像是哪个版本:npm config list (我这边已经更换最新的)
2、清空缓存:npm cache clean --force
3、然后修改镜像即可: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,查看 registry 已经被更改为默认的 npm 公共镜像地址。
也可参考:https://blog.csdn.net/maoge_666/article/details/136038003