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

问题描述

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

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

打包的时候报下面的错误
electron打包ffi-napi报错 npm ERR! gyp reason: read ECONNRESET_第1张图片

 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 [email protected]
npm ERR! gyp info using [email protected] | 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,更换了一下网络,打开手机热点,让电脑连接手机热点。
然后就打包成功了!
electron打包ffi-napi报错 npm ERR! gyp reason: read ECONNRESET_第2张图片

你可能感兴趣的:(【,踩过的坑,】,electron,ffi-napi)