安装electron 提示RequestError: certificate has expired

最近需要开发electron,遇到了一个生产问题,使用了很多办法都不生效。

现在记录下具体情况

一执行

复制代码
yarn add electron

就开始报错

复制代码
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
error /Users/xxx/test/my-electron-app/node_modules/electron: Command failed.
Exit code: 1
Command: node install.js
Arguments: 
Directory: /Users/xxx/test/my-electron-app/node_modules/electron
Output:
RequestError: certificate has expired
    at ClientRequest.<anonymous> (/Users/xxx/test/my-electron-app/node_modules/got/dist/source/core/index.js:970:111)
    at Object.onceWrapper (node:events:634:26)
    at ClientRequest.emit (node:events:531:35)
    at origin.emit (/Users/xxx/test/my-electron-app/node_modules/@szmarczak/http-timer/dist/source/index.js:43:20)
    at TLSSocket.socketErrorListener (node:_http_client:500:9)
    at TLSSocket.emit (node:events:519:28)
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
    at TLSSocket.onConnectSecure (node:_tls_wrap:1674:34)
    at TLSSocket.emit (node:events:519:28)
    at TLSSocket._finishInit (node:_tls_wrap:1085:8)
    at ssl.onhandshakedone (node:_tls_wrap:871:12)
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

自己也尝试安装证书,设置证书等等,都无效

最终解决方案如下

复制代码
# 删除 Yarn 和 npm 全局缓存
rm -rf ~/Library/Caches/Yarn
rm -rf ~/.npm

# 删除 Electron 的缓存目录(重要!)
rm -rf ~/.cache/electron

这时候执行
yarn add electron
依然还是会报错


执行这个之后就正常了
# 仅当前命令生效
NODE_TLS_REJECT_UNAUTHORIZED=0 yarn add electron
相关推荐
IT_陈寒12 分钟前
Java里用Stream.parallel()翻车实录,这性能还不如单线程
前端·人工智能·后端
wangchunyu11425 分钟前
JavaScript 零基础入门教程
前端
hanchenxing1 小时前
前端异步任务三方案:Celery vs Redis Stream vs BullMQ 实战对比消息队列
前端·数据库·redis·异步任务·方案对比
mONESY1 小时前
LangGraph.js 从零上手:把 Agent 工作流从一条线变成一张网
javascript
默_笙1 小时前
⚓ AI 的"官方答题卡":withStructuredOutput 与结构化输出的终局之战
前端·javascript
掘金挖土1 小时前
前端手摸手跑路之 AI 应用开发(五)
前端·后端
小羊没烦恼!2 小时前
Memory 记忆设计讨论:Agent Memory 的数据模型可以怎么设计
java·开发语言·前端·c++·c#
码上成长2 小时前
Mapbox 围栏编辑踩过的几个坑:key 串了、形状炸了、icon 挡住绿点
前端·前端框架
SGAMERrain3 小时前
做了一个免费的在线绘画网格工具 DrawGrid,聊聊一个小工具是怎么越做越完整的
前端
我家猫叫佩奇3 小时前
🦭 厌倦了千篇一律的线性图标?Naive Icons 正式开源
前端·javascript·css