Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new version 7.4.4 can not work with electron-builder install-app-deps #713

Closed
kevinwang930 opened this issue Oct 25, 2021 · 11 comments · Fixed by #724
Closed

new version 7.4.4 can not work with electron-builder install-app-deps #713

kevinwang930 opened this issue Oct 25, 2021 · 11 comments · Fixed by #724

Comments

@kevinwang930
Copy link

node version 16.12
electron version: 15.3
os: win 10

after install and execute electron-builder install-app-deps, abi version is 89 which should be 98

@Prinzhorn
Copy link
Contributor

This appears to be an upstream bug not related to better-sqlite3:

electron/rebuild#895
electron/rebuild#886

@kevinwang930
Copy link
Author

kevinwang930 commented Oct 25, 2021

@Prinzhorn I don't know the internals of electron-rebuild, but I spent some time reading the source code of electron-builder, especially the install-app-deps part, the source code is inside app-builder package. The logic is quite simple, it get electron version from package.json, and call npm script to rebuild native modules against target version. I think the problem may occur in the prebuild-install which depends on outdated version of node-abi, it can not get the target electron prebuild binary correctly.

electron-builder/issues/6352

@Prinzhorn
Copy link
Contributor

I think the problem may occur in the prebuild-install which depends on outdated version of node-abi, it can not get the target electron binary correctly.

We arrived at that conclusion as well in #694 (comment)

electron-builder/issues/6352

What exactly needs to change in better-sqlite3? That's the question

@mceachen
Copy link
Member

mceachen commented Oct 25, 2021

Confirmed as well: using a source dependency ala

    "better-sqlite3": "mceachen/better-sqlite3#main",

results in local recompilation, which works (but is slow, of course!)

When I upgraded to the new v7.4.4 release with electron 15.3.0 (and launching via an AppImage), I'm seeing:

(node:1732577) UnhandledPromiseRejectionWarning: Error: The module '/tmp/.mount_PhotoSTOcmHw/resources/app.asar.unpacked/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 89. This version of Node.js requires
NODE_MODULE_VERSION 98. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at process.func [as dlopen] (node:electron/js2c/asar_bundle:5:1800)
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1170:18)
    at Object.func [as .node] (node:electron/js2c/asar_bundle:5:2027)
    at Module.load (node:internal/modules/cjs/loader:982:32)
    at Module._load (node:internal/modules/cjs/loader:823:12)
    at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
    at Module.require (node:internal/modules/cjs/loader:1006:19)
    at require (node:internal/modules/cjs/helpers:93:18)
    at bindings (/tmp/.mount_PhotoSTOcmHw/resources/app.asar/node_modules/bindings/bindings.js:112:48)
    at Object.<anonymous> (/tmp/.mount_PhotoSTOcmHw/resources/app.asar/node_modules/better-sqlite3/lib/database.js:9:24)

@fullmooooon
Copy link

[1] was compiled against a different Node.js version using
[1] NODE_MODULE_VERSION 93. This version of Node.js requires
[1] NODE_MODULE_VERSION 98. Please try re-compiling or re-installing
[1] the module (for instance, using `npm rebuild` or `npm install`).

node v16.13.0
"electron": "^15.1.2",
"electron-builder": "^22.13.1",
"electron-rebuild": "^3.2.3",
win 11

I spent hours trying a lot of ways.
This seems to be an unsolvable problem at the current point in time.

"better-sqlite3": "^7.4.0" and npm rebuild .It doesn't work for me.

Now I have to use "sqlite3": "^5.0.2",

@jsaraiva
Copy link

jsaraiva commented Nov 5, 2021

This has been working for me (all of these are done in package.json):

  • add postinstall script to install dependencies:
    "scripts": { "postinstall": "electron-builder install-app-deps", ... }
  • use v7.4.0 in the dependencies:
    "dependencies": { "better-sqlite3": "7.4.0", ... }
    I haven't tried v7.4.4, though.
  • configure electron-builder to rebuild from source:
    "build": { "buildDependenciesFromSource": true, ... }

It needs to rebuild on every package addition, and I need to call "yarn" every time I update a package, but at least this way has been working for me.

Cheers!

@mckravchyk
Copy link

mckravchyk commented Nov 6, 2021

Thanks @jsaraiva Building from source was the missing piece for me .

I guess it's a temporary workaround until something changes in this package or upstream?

@jmace01
Copy link

jmace01 commented Nov 18, 2021

@jsaraiva your solution works with v7.4.4. Thanks for sharing!

@P0oOOOo0YA
Copy link

P0oOOOo0YA commented Feb 2, 2022

The same issue freezes electron-builder with 7.5.0

electron-builder install-app-deps

  • electron-builder  version=22.14.5
  • loaded configuration  file=package.json ("build" field)
  • rebuilding native dependencies  dependencies=better-sqlite3@7.5.0 platform=linux arch=x64
  • install prebuilt binary  name=better-sqlite3 version=7.5.0 platform=linux arch=x64 napi=

There is no issue with 7.4.4

@JeremyPasco
Copy link

Hi, I managed to use v7.5.0 with electron v17.0.0 (thanks to @jsaraiva !). But I had never used electron-builder before and the process was a bit tricky to me, so if it can help, here are the steps I followed:

  1. I had to switch from npm to yarn (needed to use resolution feature, and don't know how to with npm, except by editing the lock file: I don't want to)
  2. yarn add electron-builder --dev
  3. edit package.json with @jsaraiva post (scripts+dependencies+build)
  4. AND add the following into package.json: "resolution": {"node-abi": "3.31.0"}, otherwise I got the following error: Could not detect abi for version 17.0.0 and runtime electron. Updating "node-abi" might help solve this issue if it is a new release of electron. For some reason, my node-abi package was outdated, even in a fresh froject
  5. yarn install

@P0oOOOo0YA
Copy link

P0oOOOo0YA commented Feb 27, 2022

My bad. electron-builder requires build essentials in order to rebuild better-sqlite3.

After installing build essentials electron builder rebuilds 7.5.0 successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

9 participants