- Electron-Builder Version: 23.6.0
- Node Version: 14.18.1 32-bit
- Electron Version:20.3.0 and up
- Electron Type (current, beta, nightly):current
- Rebuilding native dependencies don’t work for Electron 20 and up, I added
sqlite3 v4.2.0 as dependencies to prove the issue.
- The issue doesn’t exist in Electron
v19.x.
- Here is my package.json file:
{
"name": "electron-quick-start",
"productName": "electron-quick-start",
"description": "My Electron application description",
"keywords": [],
"main": "./main.js",
"version": "1.0.0",
"author": "oalfroukh",
"scripts": {
"start": "electron .",
"dist": "electron-builder"
},
"build": {
"buildVersion": "1.0.0.0",
"compression": "normal",
"win": {
"target": "nsis",
"verifyUpdateCodeSignature": false
},
"nsis": {
"oneClick": false,
"perMachine": false,
"allowToChangeInstallationDirectory": true,
"differentialPackage": false
},
"squirrelWindows": {
"msi": "true"
},
"msi": {
"warningsAsErrors": false
},
"appx": {
"publisherDisplayName": "test"
},
"electronVersion": "20.3.0",
"buildDependenciesFromSource": true,
"nodeGypRebuild": false,
"npmRebuild": true,
"extends": null
},
"dependencies": {
"sqlite3": "4.2.0"
},
"devDependencies": {
"electron": "20.3.0",
"electron-builder": "23.6.0"
}
}
- Here is the error for the issue:
$ npm run dist
> electron-quick-start@1.0.0 dist C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start
> electron-builder
• electron-builder version=23.6.0 os=10.0.19044
• loaded configuration file=package.json ("build" field)
• writing effective config file=dist\builder-effective-config.yaml
• rebuilding native dependencies dependencies=sqlite3@4.2.0 platform=win32 arch=ia32
⨯ cannot execute cause=exit status 1
out=
> sqlite3@4.2.0 install C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3
> node-pre-gyp install --fallback-to-build
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
unpack_sqlite_dep
sqlite3.c
win_delay_load_hook.cc
sqlite3.vcxproj -> C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\Release\\sqlite3.lib
backup.cc
database.cc
node_sqlite3.cc
statement.cc
win_delay_load_hook.cc
C:\Users\oalfroukh\.electron-gyp\20.0.1\include\node\node.h(27,1): fatal error C1189: #error: "It looks like you are building this native module without using the right config.gypi. This normally means that you need to update electron-rebuild (>=3.2.8) or node-gyp (>=8.4.0) if you're building modules directly." (compiling source file ..\src\backup.cc) [C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\node_sqlite3.vcxproj]
C:\Users\oalfroukh\.electron-gyp\20.0.1\include\node\node.h(27,1): fatal error C1189: #error: "It looks like you are building this native module without using the right config.gypi. This normally means that you need to update electron-rebuild (>=3.2.8) or node-gyp (>=8.4.0) if you're building modules directly." (compiling source file ..\src\statement.cc) [C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\node_sqlite3.vcxproj]
C:\Users\oalfroukh\.electron-gyp\20.0.1\include\node\node.h(27,1): fatal error C1189: #error: "It looks like you are building this native module without using the right config.gypi. This normally means that you need to update electron-rebuild (>=3.2.8) or node-gyp (>=8.4.0) if you're building modules directly." (compiling source file ..\src\database.cc) [C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\node_sqlite3.vcxproj]
C:\Users\oalfroukh\.electron-gyp\20.0.1\include\node\node.h(27,1): fatal error C1189: #error: "It looks like you are building this native module without using the right config.gypi. This normally means that you need to update electron-rebuild (>=3.2.8) or node-gyp (>=8.4.0) if you're building modules directly." (compiling source file ..\src\node_sqlite3.cc) [C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\node_sqlite3.vcxproj]
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\oalfroukh\AppData\Roaming\nvm\v14.18.1\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\lib\binding\electron-v20.0-win32-ia32\node_sqlite3.node --module_name=node_sqlite3 --module_path=C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\lib\binding\electron-v20.0-win32-ia32 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=electron-v20.0' (1)
errorOut=node-pre-gyp WARN Using needle for node-pre-gyp https download
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\oalfroukh\AppData\Roaming\nvm\v14.18.1\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:400:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
gyp ERR! System Windows_NT 10.0.19044
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\oalfroukh\\AppData\\Roaming\\nvm\\v14.18.1\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Users\\oalfroukh\\Desktop\\Test projects\\electron-quick-start\\node_modules\\sqlite3\\lib\\binding\\electron-v20.0-win32-ia32\\node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=C:\\Users\\oalfroukh\\Desktop\\Test projects\\electron-quick-start\\node_modules\\sqlite3\\lib\\binding\\electron-v20.0-win32-ia32" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=electron-v20.0"
gyp ERR! cwd C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3
gyp ERR! node -v v14.18.1
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 'C:\Program Files\nodejs\node.exe C:\Users\oalfroukh\AppData\Roaming\nvm\v14.18.1\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\lib\binding\electron-v20.0-win32-ia32\node_sqlite3.node --module_name=node_sqlite3 --module_path=C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\lib\binding\electron-v20.0-win32-ia32 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=electron-v20.0' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\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:1058:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
node-pre-gyp ERR! System Windows_NT 10.0.19044
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\oalfroukh\\Desktop\\Test projects\\electron-quick-start\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3
node-pre-gyp ERR! node -v v14.18.1
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sqlite3@4.2.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sqlite3@4.2.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\oalfroukh\AppData\Roaming\npm-cache\_logs\2022-10-04T15_08_47_130Z-debug.log
command='C:\Program Files\nodejs\node.exe' 'C:\Users\oalfroukh\AppData\Roaming\nvm\v14.18.1\node_modules\npm\bin\npm-cli.js' rebuild sqlite3@4.2.0
workingDir=
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron-quick-start@1.0.0 dist: `electron-builder`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron-quick-start@1.0.0 dist script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\oalfroukh\AppData\Roaming\npm-cache\_logs\2022-10-04T15_08_47_205Z-debug.log
<!-- If you want, you can donate to increase issue priority (https://www.electron.build/donate) -->
So, AFAICT, I can’t do that within electron-builder, as the native dependency rebuild seems to be handled by Go-library
app-builder(-bin).That being said, what I would like to do in the next major version bump of electron-builder is to migrate it to use electron-rebuild. “Install production dependencies” would function the same with it’s conditional
npm/yarn installlogic, but anything involving app-builder-bin/node-gyp w.r.t. native dependencies would be passed through to electron-rebuild directlyOne thing we’re dependent upon is https://github.com/electron/electron-rebuild/pull/989 for
buildDependenciesFromSource, otherwise I can’t make a clean migration over. There’s some other finicky aspects of electron-rebuild, mostly due tonode-gyp/makeverbose output thatapp-builderswallows AFAICT. electron-rebuild isn’t able to discern external vs project native modules (the Go-library does ->install-app-depsversusnode-gyp-rebuild), so electron-rebuild just rebuilds all of them (i.e. both commands have the same effect if prod node_modules are already present)Seems like a minor nuisance with great benefit since we’d be migrating to an official electron package.
For the interim folks, I think a workaround is to use the electron-rebuild package directly in the
beforeBuildhook. (I actually have this setup already in a personal project)OK, but this is not a solution for the native dependencies which on npm and we have no control over it, so
electron-buildershould handle the case.I think it should be handled internally, same as in the
electron-rebuildpackage (https://github.com/electron/electron-rebuild/commit/6f94aaace0ea72a342e9249328293644caec5723), if the electron version is>= 20. Additionally, on Windows, it probably cannot be done with the help of environment variables. How to set thestd:c++17flag depending on the platform: https://github.com/electron/electron/pull/33906#discussion_r870859269Hmm, I’m either not seeing the option to configure it or it does not appear to be configurable via env vars. Which variable exactly do you mean? I suppose it would have to be this option: https://github.com/nodejs/node-gyp/issues/1662#issuecomment-754283275
I seem to be having the same issue when upgrading from electron 19 to 20. Rebuilding native modules fails due to
c++17not being used, but it seems that there’s no option to pass such flags tonode-gypthroughelectron-builder:Thanks @mmaietta the issue is fixed from
Electronside https://github.com/electron/electron/pull/36383 in the latest versions (v21.3.1 and 20.3.7)Hi @mmaietta Still there is an issue in
/std:c++17seemsElectron rebuilddoesn’t handle it already there is a reported issue to Electron rebuild, or shall you handle it fromElectron-builderitself?Thanks for your help!
We are using v21.1.0 and 24.0.0-alpha.1 and it’s working on GitHub Actions(macOS-latest, Windows-2022, and Ubuntu-22.04) Thank you, @mmaietta!
Quick update: Release 24.0.0-alpha.1 is the migration to electron-rebuild so you don’t need the workaround. Please give it a shot (just note the breaking changes 🙂)