npm 淘宝镜像到期了,尽快切换~(npm使用淘宝镜像安装时报错)
npm使用淘宝镜像安装时突然报错了错误及解决方案如下:
一、错误内容:
npm err! request to https://registry.npm.taobao.org/cnpm failed, reason: certificate has expired
npm err! code cert_has_expired npm err! errno cert_has_expired npm err! request to https://registry.npm.taobao.org/cnpm failed, reason: certificate has expired npm err! a complete log of this run can be found in: d:\nodejs\node_cache\_logs\2024-01-23t11_00_28_143z-debug-0.log
二、解决方案:
方法①:可以解决但建议用第二种方法
// 1. 清空缓存 npm cache clean --force // 2. 关闭ssl验证 npm config set strict-ssl false // 3. 安装 到这里就可以正常使用npm命令安装需要的工具了。如( npm install -g cnpm )
方法②:将npm淘宝镜像切换至淘宝的新镜像域名
// 1. 清空缓存 npm cache clean --force // 2. 切换新源 npm config set registry https://registry.npmmirror.com // 3. 查看源是否设置成功 npm config get registry // 4. 安装 到这里就可以正常使用npm命令安装需要的工具了。如( npm install -g cnpm )
三、出错原因:
2024年1 月 22 日,淘宝原镜像域名(registry.npm.taobao.org)的 https 证书正式到期。这就导致旧的 npm 淘宝镜像在使用时出错了:
众所周知,npm 官方镜像(registry.npmjs.org)在国内访问很慢,很多人都会选择切换到国内的 淘宝npm镜像。
其实,早在 2021 年,淘宝就发文称,npm 淘宝镜像已经从 registry.npm.taobao.org
切换到了 registry.npmmirror.com
。旧域名也将于 2022 年 5 月 31 日停止服务(不过,直到昨天 https 证书到期才真正不能用了)。
淘宝文件内容如下:
所以,遇到上述问题,或者还在使用旧的 npm 淘宝镜像,直接将 npm 源切换到新的源即可:即本文中的解决方法②。
到此这篇关于npm使用淘宝镜像安装时报错的解决方案的文章就介绍到这了,更多相关npm淘宝镜像安装报错内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!
发表评论