【Node.js】npm ERR! request to https://registry.npm.taobao.org/cnpm failed … certificate has expired 报错问题
问题描述
在使用NPM安装包的过程中,出现以下错误:
1 | npm ERR! code CERT_HAS_EXPIRED |
原因分析
请求到的 https://registry.npm.taobao.org/cnpm 失败,原因是证书已经过期。
2024年1月22日,淘宝NPM镜像站的域名 registry.npm.taobao.org 的SSL证书过期。
解决方案
1 清理NPM的缓存
1 | npm cache clean --force |
2 切换到新的NPM镜像站
1 | npm config set registry https://registry.npmmirror.com |
3 检查是否成功切换到新的镜像站
1 | npm config get registry |
如果这个命令返回的是 https://registry.npmmirror.com,那么就说明已经成功切换到了新的镜像站。