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

相关推荐
GISer_Jing26 分钟前
浏览器 Agent 插件开发规格书 (SPEC)
前端·ai·前端框架·edge浏览器
别叫我->学废了->lol在线等39 分钟前
评估总结模块(暂不做)
前端
清灵xmf1 小时前
CC Switch:解决 AI 编程工具配置
前端·人工智能·cc switch
IT_陈寒1 小时前
Redis缓存击穿把我坑惨了,原来这样解决才靠谱
前端·人工智能·后端
mfxcyh1 小时前
Vue3 右键菜单实现方案(基于 vue3-context-menu)
前端
treesforest1 小时前
从IP地址归属地查询到IP地理位置精准查询指南
服务器·前端·网络
LF男男1 小时前
WindmillBullect.cs
前端
小白学大数据1 小时前
Python 爬虫爬取应用商店数据:请求构造与数据解析
前端·爬虫·python·数据分析
pkowner1 小时前
若依分页问题及解决方法
java·前端·算法
golang学习记2 小时前
Cursor官方团队的AI指南:Cursor Team Kit
前端·cursor