I'm developing a desktop application based on Electron and I use electron-packager to create executable binary files on Mac OSX and Windows. My development box is on Mac OSX. In the my application, it uses some native node modules (like bcrypt). By saying native, I mean they are compiled to binary code when being installed by npm install
On my Mac, I package the app (using electron-packager) for Windows OS (packaging settings target to Windows 64 bits). And when I run the outcome package (.exe file along with other necessary files) on Windows 8.1 64 bits, an error appears at app launching

However, this problem won't appear if the packaging takes place on a Windows OS (development tools like electron, electron-packager, node, etc. are available).
My question: Is there any practice or electron-based packaging tool (either electron-packager or else) that runs on one OS (either Mac OSX, Windows or Linux) and produce executable file targeted on different OS. For instance, I'd like to use that tool on my Mac and produce three executable packages on 03 different OS: Windows OS 32 bits, Windows OS 64 bits and Mac OSX.
Perhaps someone with better knowledge of the node ecosystem can answer how to cross-compile native node modules for packaging.
+1. Would love to know the answer for this. It is a pain to have to run packager on every platform that needs supporting as opposed to running it once. Sort of the defeating the platform: 'all' option .
The electron-packager module doesn't do anything special to help you compile native modules, thats totally up to the maintainer to compile and is outside the scope of this module. However, if someone has a concrete proposal (e.g. an API proposal) that could make the packaging part easier that integrates with something else that handles compilation then I would be all ears.
@malept @buunguyen to build platform specific modules with node, you use node-gyp to standardise the build process and build on the target OS (so you have the correct compiler and libs). TMK there is no current way of compiling a node module with native extensions on an OS that is different to the target OS of the extension.
The only support that electron-packager could reasonably give here is API support to grab pre-compiled platform specific binaries from a specified location and incorporate into the build - similar to what electron-prebuilt does for electron itself. Grabbing binaries from the wild is rightly frowned upon - hence platform specific builds.
@maxogden If electron-packager had an option that automatically ran https://github.com/electronjs/electron-rebuild with the correct options present it would greatly simplify native module workflows.
@MarshallOfSound
Seems electron-rebuild is to fix the native modules broken between different node version, for Electron's node version differ to the node when npm installing.
But electron-rebuild cannot fix this issue, at least not completely. The problem here is some native modules get broken across platforms, like Windows and Mac.
And I think a big trouble is for npm doesn't mark modules with what platform they supports. I can hardly pick out the portable modules that can be relied on after distribution.
@towertop electron-builder calls rebuild. But cross-compilation is not supported. And it is not electron-packager/electron-builder task — instead, authors of such modules _should_ use https://www.npmjs.com/package/node-pre-gyp and simplify developers life. Maybe someday electron-builder will support it (precompile, upload to bintray, and use it in the all next builds).
I think at this point, the solution is to use multi-OS CI services plus electron-rebuild to deal with this problem. There's nothing Electron Packager can do, and even if cross-compilation was supported by node-gyp, I think that the code itself would live in an electron-rebuild hook (like #359).
Any news on this? I also face the problem that my CI build (on Linux) building my electron app for OSX packages the linux bindings for sqlite instead of the OSX bindings.
@choffmeister Just use https://www.npmjs.com/package/prebuild for your native module or send corresponding PR to use it in the used native module. It is not electron-packager/electron-builder issue.
Most helpful comment
@towertop electron-builder calls rebuild. But cross-compilation is not supported. And it is not electron-packager/electron-builder task — instead, authors of such modules _should_ use https://www.npmjs.com/package/node-pre-gyp and simplify developers life. Maybe someday electron-builder will support it (precompile, upload to bintray, and use it in the all next builds).