npm install|certificate has expired 证书过期

使用 npm install 命令安装 Node.js 项目的依赖时,遇到 "certificate has expired" 错误,可能是连接到的某个服务器上的 SSL/TLS 证书已经过期。也可能是正在使用的 npm 仓库(通常是 npm 官方仓库)或者中间代理服务器的证书没有得到及时更新

复制代码
sh-3.2# npm install
npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/yauzl/download/yauzl-2.10.0.tgz failed, reason: certificate has expired

npm ERR! A complete log of this run can be found in: /var/root/.npm/_logs/2024-04-25T02_04_01_904Z-debug-0.log

遇到 npm ERR! code CERT_HAS_EXPIRED 错误时,尝试从淘宝的npm镜像(registry.npm.taobao.org)下载包时,由于SSL/TLS证书问题而失败了

我这里简单粗暴,禁用 strict-ssl ,允许继续使用该镜像

复制代码
npm config set strict-ssl false

将 npm 的 strict-ssl 设置为 false 会使 npm 在与仓库通信时忽略 SSL 证书错误,绕过 npm 在安装过程中对 SSL 证书的检查

附上镜像源

npm config set registry https://registry.npmjs.org/

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

相关推荐
LaughingZhu1 小时前
Product Hunt 每日热榜 | 2026-05-21
前端·人工智能·经验分享·chatgpt·html
怕浪猫1 小时前
Electron 开发实战(一):从零入门核心基础与环境搭建
前端·electron·ai编程
小鹏linux2 小时前
Ubuntu 22.04 部署开源免费具有精美现代web页面的Casdoor账号管理系统
linux·前端·ubuntu·开源·堡垒机
前端若水3 小时前
会话管理:创建、切换、删除对话历史
前端·人工智能·python·react.js
Bigger3 小时前
mini-cc:一个轻量级 AI 编程助手的诞生
前端·ai编程·claude
涵涵(互关)3 小时前
Naive-ui树型选择器只显示根节点
前端·ui·vue
BY组态3 小时前
Ricon组态系统最佳实践:从零开始构建物联网监控平台
前端·物联网·iot·web组态·组态
BY组态4 小时前
Ricon组态系统vs传统组态软件:为什么选择新一代Web组态平台
前端·物联网·iot·web组态·组态
SoaringHeart4 小时前
Flutter进阶:OverlayEntry 插入图层管理器 NOverlayZIndexManager
前端·flutter
放下华子我只抽RuiKe54 小时前
React 从入门到生产(四):自定义 Hook
前端·javascript·人工智能·深度学习·react.js·自然语言处理·前端框架