npm 淘宝镜像到期,error An unexpected error occurred: “https://registry.npm.taobao.org

Andy 2024年12月16日 222次浏览

起因:今天周一,下载新依赖的时候报错。

error An unexpected error occurred: "https://registry.npm.taobao.org/naive-ui: certificate has expired".

在 1 月 22 日,淘宝原镜像域名(registry.npm.taobao.org)的 HTTPS 证书正式到期。如果想要继续使用,需要将 npm 源切换到新的源(registry.npmmirror.com),否则会报错。

解决方法:

切换新的镜像地址
如果你使用淘宝命令工具cnpm,则不需要去手动更新镜像地址,官方已自动做了处理。
如果你是将npm官方镜像改成了淘宝镜像,则需要按下面步骤去手动更新。

清空缓存

npm cache clean --force

切换新源

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