You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm just trying to understand what's going on here.
2. Background / The part that works
My electron app is using node-keytar [1], which is a native module. After installing with npm install keytar --save, running the app in development with my gulp && electron . command works fine.
Building with electron-builder (gulp && electron-builder) to produce a universal build also works fine, with the production app opening correctly on both m1 and intel (via Rosetta) arches. Relevant logs from building on m1 mac:
[1] - Not sure if relevant, but node-keytar v7.7.0 (which is what I'm using) uses N-API prebuilds.
3. Issue / The part that breaks
The app however crashes when subsequently running in development again, the app window opens and errors out immediately as long as I have const keytar = require('keytar'); in my app. I've reliably replicated this locally. This is the error I get in devtools:
Uncaught Error: dlopen(/app_path/node_modules/keytar/build/Release/keytar.node, 1): no suitable image found. Did find:
/app_path/node_modules/keytar/build/Release/keytar.node: mach-o, but wrong architecture
/app_path/node_modules/keytar/build/Release/keytar.node: mach-o, but wrong architecture
at process.func [as dlopen] (electron/js2c/asar_bundle.js:5)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1138)
at Object.func [as .node] (electron/js2c/asar_bundle.js:5)
at Module.load (internal/modules/cjs/loader.js:935)
at Module._load (internal/modules/cjs/loader.js:776)
at Function.f._load (electron/js2c/asar_bundle.js:5)
at Function.o._load (electron/js2c/renderer_init.js:33)
at Module.require (internal/modules/cjs/loader.js:959)
at require (internal/modules/cjs/helpers.js:88)
at Object.<anonymous> (/app_path/node_modules/keytar/lib/keytar.js:1:169)
4. Findings / workaround
I've also found that re-installing keytar (with npm uninstall keytar, followed by npm install keytar --save) fixes the issue in development, and building for production thereafter continues to work and isn't adversely affected.
My uneducated, layman guess is that the build process is leaving keytar to use the arm64 arch prebuild after it's been built with electron-builder, as it comes after the x64 install prebuilt binary step. So when the app is run in development (which uses the x64 arch) again, it ends up not working.
5. Actual question
So as stated above, I'm just trying to find out if my guess is right, or am I misguided here? I would appreciate some clues and guidance, if possible. Suggestions for possible cleaner workflows regarding the workaround fix would certainly also be appreciated.
The text was updated successfully, but these errors were encountered:
1. Motivation
I'm just trying to understand what's going on here.
2. Background / The part that works
My electron app is using node-keytar [1], which is a native module. After installing with
npm install keytar --save
, running the app in development with mygulp && electron .
command works fine.Building with electron-builder (
gulp && electron-builder
) to produce a universal build also works fine, with the production app opening correctly on both m1 and intel (via Rosetta) arches. Relevant logs from building on m1 mac:[1] - Not sure if relevant, but node-keytar v7.7.0 (which is what I'm using) uses N-API prebuilds.
3. Issue / The part that breaks
The app however crashes when subsequently running in development again, the app window opens and errors out immediately as long as I have
const keytar = require('keytar');
in my app. I've reliably replicated this locally. This is the error I get in devtools:4. Findings / workaround
I've also found that re-installing keytar (with
npm uninstall keytar
, followed bynpm install keytar --save
) fixes the issue in development, and building for production thereafter continues to work and isn't adversely affected.My uneducated, layman guess is that the build process is leaving keytar to use the arm64 arch prebuild after it's been built with electron-builder, as it comes after the x64 install prebuilt binary step. So when the app is run in development (which uses the x64 arch) again, it ends up not working.
5. Actual question
So as stated above, I'm just trying to find out if my guess is right, or am I misguided here? I would appreciate some clues and guidance, if possible. Suggestions for possible cleaner workflows regarding the workaround fix would certainly also be appreciated.
The text was updated successfully, but these errors were encountered: