小工具知识网

当前位置: 首页 > 行业知识 > npm 淘宝镜像到期了,尽快切换(npm使用淘宝镜像安装时报错)

行业知识

npm 淘宝镜像到期了,尽快切换(npm使用淘宝镜像安装时报错)

2026-11-01 04:43:57 来源:互联网转载

npm 淘宝镜像到期了,尽快切换~(npm使用淘宝镜像安装时报错)

★npm使用淘宝镜像安装时突然报错了错误及解决方案如下。

一、错误内容:

npm ERR! request to https://registry.npm.taobao.org/cnpm failed, reason: certificate has expired

npm ERR! code CERT_HAS_EXPIREDnpm ERR! errno CERT_HAS_EXPIREDnpm ERR! request to https://registry.npm.taobao.org/cnpm failed, reason: certificate has expirednpm ERR! A complete log of this run can be found in: D:\nodejs\node_cache\_logs24-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 源切换到新的源即可:即本文中的解决方法②。

上一篇:揭秘数据库图标全貌,探索图标背后的深层秘密!

下一篇:吉吉获取攻略大揭秘,轻松掌握,轻松获取吉吉!