问题描述
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