Incorrect prebuilt binary selected on build
I'm running in to an issue building, not sure if this better-sqlite3 related or another config. I'm getting:
Error: dlopen(/.../node_modules/better-sqlite3/build/Release/better_sqlite3.node, 0x0001): tried: '/.../node_modules/better-sqlite3/build/Release/better_sqlite3.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
I'm running macOS 12 (m1 Mac), electron-forge, electron 19.0.10.
Same error for me too. Using MACBOOK PRO M1 - MAC OS 12 (VSCODE IDE)
"devDependencies": { "electron": "^21.1.1", "electron-rebuild": "^3.2.9" }, "dependencies": { "better-sqlite3-with-prebuilds": "^7.4.3" }
Error: dlopen(/Users/
请问目前这个问题,有人有解法么?
Also getting this on an M1 MacBook running Monterey 12.4 (21F79).
Error:
node:internal/modules/cjs/loader:1243
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: dlopen(/Users/<REDACTED>/node_modules/better-sqlite3/build/Release/better_sqlite3.node, 0x0001): tried: '/Users/<REDACTED>/node_modules/better-sqlite3/build/Release/better_sqlite3.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
package.json
"dependencies": {
"better-sqlite3": "^8.0.1"
},
Noticed that it was not erring with Node 14.8.3 so I tried some more versions. For me it works with 15.14.0 and starts erring on 16.0.0.
Relevant in the changelog:
Node.js v16.0.0 will be the first release where we ship prebuilt binaries for Apple Silicon. While we’ll be providing separate tarballs for the Intel (darwin-x64) and ARM (darwin-arm64) architectures the macOS installer (.pkg) will be shipped as a ‘fat’ (multi-architecture) binary.
I use n for managing my Node.js versions and I noticed this in their documentation:
On a Mac with Apple silicon:
- for Node.js 16 and higher,
ndefaults to arm64 binaries which run natively- for older versions of Node.js,
ndefaults to x64 binaries which run in Rosetta 2
So I decided to try both the arm64 and x64 binaries of 16.0.0:
$ n rm 16.0.0
$ n --arch arm64 16.0.0
installing : node-v16.0.0
mkdir : /usr/local/n/versions/node/16.0.0
fetch : https://nodejs.org/dist/v16.0.0/node-v16.0.0-darwin-arm64.tar.xz
installed : v16.0.0
$ node index.js
# errors
$ n rm 16.0.0
$ n --arch x64 16.0.0
installing : node-v16.0.0
mkdir : /usr/local/n/versions/node/16.0.0
fetch : https://nodejs.org/dist/v16.0.0/node-v16.0.0-darwin-x64.tar.xz
installed : v16.0.0
$ node index.js
# does not error
Based on this observed behavior, it seems there's a compatibility issue with the arm64 binaries.
I see a lot of discussion about this going on over at #601, so maybe this is a duplicate. Though I'm not using Electron as better-sqlite3 is my sole dependency.
I also see a recent related PR (#859) though that seems to be merged and present on 8.0.1 which is what I've been testing against locally.
package-lock.json
"node_modules/better-sqlite3": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-8.0.1.tgz",
"integrity": "sha512-JhTZjpyapA1icCEjIZB4TSSgkGdFgpWZA2Wszg7Cf4JwJwKQmbvuNnJBeR+EYG/Z29OXvR4G//Rbg31BW/Z7Yg==",
"hasInstallScript": true,
"dependencies": {
"bindings": "^1.5.0",
"prebuild-install": "^7.1.0"
}
},
Note: I went ahead and installed node-gyp globally, as recommended in the troubleshooting documentation. But it didn't seem to have an impact on this.
I have an opposite issue:
…but is an incompatible architecture (have 'arm64', need 'x86_64')…
I'm running macOS 13.1 (Apple M1), electron-forge 6.0.4, electron 22.0.2, better-sqlite3 8.0.1 any ideas how to solve?
Got this fixed by downgrading electron-forge from 6.0.4 to 6.0.0
So looks like this issue has nothing to do with better-sqlite3
rebuild:npm rebuild --runtime=electron --arch=arm64 --target=22.3.2 --disturl=https://atom.io/download/atom-shell --abi=110 npm run rebuild
i use [email protected],my node modules is 110 you can do process.versions.modules see your electron node modules,then replace params