electron-builder: Inconsistent build behavior regarding asar file
- Electron-Builder Version: 23.6.0
- Node Version: 18.13.0
- Electron Version: 23.2.0
- Electron Type (current, beta, nightly): current
- Target: windows
Hi! I tried to prepare a distribution that targets Windows. When I run the build process on a Windows machine everything is fine and the app works perfectly, but when I run the build process on a MacOS app crashes during the start with the following error “A JavaScript error occurred in the main process”(screenshot below). What I noticed is that the resources folder differs between OSes. Any ideas about what have I missed?
Error
[Windows] Resources folder
[MacOS] Resources folder
Reproduction steps:
- Clone https://github.com/lkowalczyk87/asar-issue-electron-build
- Run
npm ci - Run
npm run build-win
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 7
- Comments: 24
Thanks @mmaietta 24.5.1 seems to fix the rebuild issue! it means I can drop the
buildDependenciesFromSourceandnpmRebuildletting it recompile for the target platform 😃I’ve avoided reintroducing the postinstall script as that doesnt seem to have changed, so am not sure it would be useful at this stage. Let me know if you would like me to test it…
Thank you for verifying!
It should work with the postinstall script, it’s running everything the same under the hood. That being said, I couldn’t have it distinguish between internal vs external modules since that was originally done by the app-builder-bin Go binary, so I couldn’t fetch the different modules to build. Now, electron/rebuild just handles everything
Okay, thanks for checking!
I have a strong hunch this is the case, it significantly predates me joining as a maintainer.
Can you try
nextv24.5.1? I reconfigured electron-builder to use the @electron/rebuild API directly as opposed to the entry point in https://github.com/electron-userland/electron-builder/pull/7629 so that it respects the destinationplatforminstead of forcingprocess.platformThere are so many edge cases with native builds that it’s proving significantly difficult to capture all cases. The harder part is making sure that the unit test passes, but then there’s no way to test if the app actually runs ☹️
Hi @mmaietta thanks for your help. Here is a subset of the output from the console.log, the full output can be found in the attached file
shouldUnpack.txt