优秀的编程知识分享平台

网站首页 > 技术文章 正文

npm 报错:CERT_HAS_EXPIRED npm 报错 could not resolve

nanyue 2024-12-30 05:59:49 技术文章 4 ℃

问题描述

npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/pnpm failed, reason: certificate has expired

错误原因

淘宝镜像过期了!

在 2021 年,淘宝就发文称,npm 淘宝镜像已经从 http://registry.npm.taobao.org 切换到了 http://registry.npmmirror.com。旧域名也将于 2022 年 5 月 31 日停止服务(直到 HTTPS 证书到期才真正不能用了)

2024年1 月 22 日,淘宝原镜像域名(http://registry.npm.taobao.org)的 HTTPS 证书正式到期,导致旧的 npm 淘宝镜像在使用时出错了。

解决方案

  1. 清空缓存
npm cache clean --force
  1. 查看当前的npm镜像设置
npm config get registry
未更新新源前会输出: https://registry.npm.taobao.org/
  1. 切换新源
 npm config set registry https://registry.npmmirror.com
  1. 查看新源是否设置成功
npm config get registry
更换新源后会输出: https://registry.npmmirror.com
  1. 正常安装依赖
npm install
最近发表
标签列表