electron-builder rebuild sqlite3 在https://atom.io/download/electron/下载headers文件失败问题解决

问题描述

electron-builder 打包应用时,在rebuilding sqlite3过程中node-pre-gyp http 403 https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.2.0/electron-v7.3-linux-arm64.tar.gz ,Pre-built binaries not found,所以需要下载electron node-v7.3.3-headers.tar.gz进行编译,但是默认disturl地址下载无法得到正确的headers文件导致编译失败

完整报错信息如下:

Error output:
warning ../../package.json: License should be a valid SPDX license expression
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.11.0
node-pre-gyp info using node@14.20.0 | linux | arm64
node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp http GET https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.2.0/electron-v7.3-linux-arm64.tar.gz
node-pre-gyp http 403 https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.2.0/electron-v7.3-linux-arm64.tar.gz
node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.2.0/electron-v7.3-linux-arm64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for sqlite3@4.2.0 and electron@7.3.3 (electron-v7.3 ABI, glibc) (falling back to source compile with node-gyp) 
node-pre-gyp http 403 status code downloading tarball https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.2.0/electron-v7.3-linux-arm64.tar.gz 
gyp info it worked if it ends with ok
gyp info using node-gyp@5.1.0
gyp info using node@14.20.0 | linux | arm64
gyp info ok 
gyp info it worked if it ends with ok
gyp info using node-gyp@5.1.0
gyp info using node@14.20.0 | linux | arm64
gyp info find Python using Python version 2.7.16 found at "/usr/bin/python"
gyp http GET https://atom.io/download/electron/v7.3.3/node-v7.3.3-headers.tar.gz
gyp http 200 https://atom.io/download/electron/v7.3.3/node-v7.3.3-headers.tar.gz
gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: There was a fatal problem while downloading/extracting the tarball
gyp ERR! stack     at Unpack.afterTarball (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:212:21)
gyp ERR! stack     at Unpack.emit (events.js:400:28)
gyp ERR! stack     at Unpack.[maybeClose] (/usr/lib/node_modules/npm/node_modules/tar/lib/unpack.js:217:12)
gyp ERR! stack     at Unpack.opt.ondone (/usr/lib/node_modules/npm/node_modules/tar/lib/unpack.js:131:23)
gyp ERR! stack     at Unpack.emit (events.js:400:28)
gyp ERR! stack     at Unpack.[emit] (/usr/lib/node_modules/npm/node_modules/tar/lib/parse.js:235:12)
gyp ERR! stack     at Unpack.[maybeEnd] (/usr/lib/node_modules/npm/node_modules/tar/lib/parse.js:351:17)
gyp ERR! stack     at Unpack.[consumeChunk] (/usr/lib/node_modules/npm/node_modules/tar/lib/parse.js:380:21)
gyp ERR! stack     at Unpack.write (/usr/lib/node_modules/npm/node_modules/tar/lib/parse.js:315:25)
gyp ERR! stack     at Unpack.end (/usr/lib/node_modules/npm/node_modules/tar/lib/parse.js:424:14)
gyp ERR! System Linux 4.19.0-arm64-desktop
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/home/baixin/rpa-robot-linux/node_modules/sqlite3/lib/binding/electron-v7.3-linux-arm64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/home/baixin/rpa-robot-linux/node_modules/sqlite3/lib/binding/electron-v7.3-linux-arm64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=electron-v7.3"
gyp ERR! cwd /home/baixin/rpa-robot-linux/node_modules/sqlite3
gyp ERR! node -v v14.20.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/home/baixin/rpa-robot-linux/node_modules/sqlite3/lib/binding/electron-v7.3-linux-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/home/baixin/rpa-robot-linux/node_modules/sqlite3/lib/binding/electron-v7.3-linux-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=electron-v7.3' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/baixin/rpa-robot-linux/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1088:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5)
node-pre-gyp ERR! System Linux 4.19.0-arm64-desktop
node-pre-gyp ERR! command "/usr/bin/node" "/home/baixin/rpa-robot-linux/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/baixin/rpa-robot-linux/node_modules/sqlite3
node-pre-gyp ERR! node -v v14.20.0
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok 
error Command failed with exit code 1.

    at ChildProcess.<anonymous> (/home/baixin/rpa-robot-linux/node_modules/builder-util/src/util.ts:244:14)
    at Object.onceWrapper (events.js:520:26)
    at ChildProcess.emit (events.js:400:28)
    at maybeClose (internal/child_process.js:1088:16)
    at Socket.<anonymous> (internal/child_process.js:446:11)
    at Socket.emit (events.js:400:28)
    at Pipe.<anonymous> (net.js:686:12)
From previous event:
    at processImmediate (internal/timers.js:464:21)
From previous event:
    at /home/baixin/rpa-robot-linux/node_modules/app-builder-lib/src/util/yarn.ts:155:24
From previous event:
    at _rebuild (/home/baixin/rpa-robot-linux/node_modules/app-builder-lib/src/util/yarn.ts:179:5)
    at rebuild (/home/baixin/rpa-robot-linux/node_modules/app-builder-lib/out/util/yarn.js:163:19)
    at /home/baixin/rpa-robot-linux/node_modules/app-builder-lib/src/util/yarn.ts:20:11
From previous event:
    at _installOrRebuild (/home/baixin/rpa-robot-linux/node_modules/app-builder-lib/out/util/yarn.js:71:28)
    at installOrRebuild (/home/baixin/rpa-robot-linux/node_modules/app-builder-lib/out/util/yarn.js:55:28)
    at /home/baixin/rpa-robot-linux/node_modules/electron-builder/src/cli/install-app-deps.ts:58:9
    at Generator.next (<anonymous>)
    at processImmediate (internal/timers.js:464:21)
From previous event:
    at _installAppDeps (/home/baixin/rpa-robot-linux/node_modules/electron-builder/out/cli/install-app-deps.js:177:26)
    at installAppDeps (/home/baixin/rpa-robot-linux/node_modules/electron-builder/out/cli/install-app-deps.js:146:26)
    at /home/baixin/rpa-robot-linux/node_modules/electron-builder/src/cli/cli.ts:49:19
error Command failed with exit code 1.

问题分析

从堆栈信息中看到如下内容
gyp info find Python using Python version 2.7.16 found at "/usr/bin/python"
gyp http GET https://atom.io/download/electron/v7.3.3/node-v7.3.3-headers.tar.gz
gyp http 200 https://atom.io/download/electron/v7.3.3/node-v7.3.3-headers.tar.gz
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: There was a fatal problem while downloading/extracting the tarball
gyp ERR! stack at Unpack.afterTarball (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:212:21)

推测为headers文件问题,手动下载https://atom.io/download/electron/v7.3.3/node-v7.3.3-headers.tar.gz 发现得到的文件实际为html格式,即未下载得到正确的headers文件

问题解决

执行如下命令

yarn config set disturl https://electronjs.org/headers
或
npm config set disturl https://electronjs.org/headers
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 215,634评论 6 497
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,951评论 3 391
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 161,427评论 0 351
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,770评论 1 290
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,835评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,799评论 1 294
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,768评论 3 416
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,544评论 0 271
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,979评论 1 308
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,271评论 2 331
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,427评论 1 345
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,121评论 5 340
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,756评论 3 324
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,375评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,579评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,410评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,315评论 2 352

推荐阅读更多精彩内容