electron打包ffi-napi报错 npm ERR! gyp reason: read ECONNRESET

问题描述

这个问题用了我两天的时间,所以记录一下。

我们项目是使用electron+vue,做支付功能的时候需要使用到ffi-napi依赖包。
最后打包的时候ffi-napi报错了,在package.json中去掉ffi-napi就可以打包,但是打包运行后提示缺少ffi-napi,所以必须带着ffi-napi打包。

打包的时候报下面的错误
在这里插入图片描述

 OKAY  take it away `electron-builder`

  • electron-builder version=20.44.4
  • loaded configuration file=package.json ("build" field)
  • writing effective config file=build\builder-effective-config.yaml
  • rebuilding native production dependencies platform=win32 arch=ia32
Error: C:\Program Files (x86)\nodejs\node.exe exited with code 1
Error output:
npm ERR! code 1
npm ERR! path D:\Project\zyd-windows\node_modules\ffi-napi
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp-build
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@14.17.0 | win32 | ia32
npm ERR! gyp info find Python using Python version 3.8.5 found at "C:\Users\yaoqi\AppData\Local\Programs\Python\Python38\python.exe"
npm ERR! gyp http GET https://atom.io/download/electron/v9.4.4/node-v9.4.4-headers.tar.gz
npm ERR! gyp WARN install got an error, rolling back install
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack FetchError: request to https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist/v9.4.4/node-v9.4.4-headers.tar.gz failed, reason: read ECONNRESET
npm ERR! gyp ERR! stack     at ClientRequest.<anonymous> (D:\Project\zyd-windows\node_modules\minipass-fetch\lib\index.js:110:14)
npm ERR! gyp ERR! stack     at ClientRequest.emit (events.js:376:20)
npm ERR! gyp ERR! stack     at TLSSocket.socketErrorListener (_http_client.js:475:9)
npm ERR! gyp ERR! stack     at TLSSocket.emit (events.js:388:22)
npm ERR! gyp ERR! stack     at emitErrorNT (internal/streams/destroy.js:106:8)
npm ERR! gyp ERR! stack     at emitErrorCloseNT (internal/streams/destroy.js:74:3)
npm ERR! gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:82:21)
npm ERR! gyp ERR! System Windows_NT 10.0.22000
npm ERR! gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "D:\\Project\\zyd-windows\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd D:\Project\zyd-windows\node_modules\ffi-napi
npm ERR! gyp ERR! node -v v14.17.0
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok

核心问题

上面的错误主要是
npm ERR! gyp ERR! stack FetchError: request to https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist/v9.4.4/node-v9.4.4-headers.tar.gz failed, reason: read ECONNRESET

解决过程

刚开始我以为是ffi-napi依赖包的问题,然后重新npm install了好多次,打包依然是这个问题。
然后百度有人说是镜像源的问题,换了镜像源还是不行。

最后仔细看了报错里面最后原因是read ECONNRESET,网上其他人报错都是403,我的是根本没连接上服务器。然后我就怀疑是网络的问题。因为我连的是公司的网络,公司的网络经常会屏蔽一些东西,比如哔哩哔哩就打不开。

解决方法

我本来连的是公司的wifi,更换了一下网络,打开手机热点,让电脑连接手机热点。
然后就打包成功了!
在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值