Node Native AddOn in Electron Cross-Platform Use - node.js

If I use a Node native addon in an Electron app that will be used on Mac and Windows, do I need to do anything special to ensure that the correct flavor of the add-on (Mac or Windows) is used in each build? I'm developing on Windows, but users will also be running on Mac. I'll build the output with Electron-Builder.
Thanks.

Related

How to run an Electron .exe app on Linux?

I'm trying to run an application build with Electron on Linux. They app maker offers an .exe installation file. So I figured I'd install it in WINE, but I seem to be missing something the app needs to run.
Since the install is an .exe, do I need WINE? And if I need WINE, what do I need to install to make the app work? I have tried two Electron apps, both only downloadable as a .exe install file.
Electron adds os native calls, so .exe files usually do not work. WINE is not able to emulate all of those calls, so if it isn't working for you, then you are out of luck I guess. Look for apps that offer linux versions, like https://www.electronjs.org/apps/camunda-modeler. If you have access to the repository, chances are they build it using electron-builder. You can just build it yourself with the command electron-builder build --linux in most cases

Can we rebuild node native module on Linux for win32 platform using node-gyp?

I've created an electron application which uses two NodeJS native modules node ref and node ffi. The application is being developed on windows right now and the windows executable is generated with the help of electron-builder. This all works perfectly fine and the application is installed in windows properly. As both ffi and ref are native modules, I'm simply use electron-rebuild to rebuild them for platform win32 (I guess that internally uses node-gyp).
But the problem is, my CI/CD server is Ubuntu 16 and I need to generate the windows executable file there. If my application doesn't have node's native addons, it works fantastic but with native modules included, the exe file is generated but on launch it says %1 is not a win32 application and the reason for that is, the native deps are rebuilt for Linux platform instead of windows.
So I wanted to know is, is there any way to rebuild the node native modules on Linux machine for win32 platform or if its not possible then how can we use the pre-built .node file across the platforms.

Node-webkit multi platform native module with nw-gyp

I'm currently writing a node-webkit application which uses a native module (lwip). I found out that I need to compile native modules with nw-gyp.
After using nw-gyp a new file lwip_image.node will be created under node_modules/lwip/build/Release.
How is the native module required? Like this: var lwip_image = require('./node_modules/lwip/build/Release/lwip_image.node') ??
If the native module was created on Win8 x64, will it also work on Win7 x64 or even Win8/7 x32? Same question for Mac vs Ubuntu x32 vs Ubuntu x64?
To facilitate the build process I would build the native modules on the target platforms once. After that I would like to copy them all to my project dir so I can automate the build process to build it for all platforms at once. How would I go about that? Use os.platform() and require depending on platform? ...
UPDATE: Those posts were what I was looking for: https://github.com/joyent/node/issues/4398#issuecomment-11233144
https://github.com/npm/npm/issues/1891
Your module's short name will be used in "require"
Your 32-bit code (compiled with target=ia32) will work on 64-bit platform, but not the other way around
After you have compiled your module for all platforms, it should be enough to pack different zip, .app or .exe versions for different platforms, with different respective binaries of your module.

TideSDK app on Mac

I developed an app via TideSDK on OSX. I have a .app and It is working on OSX. However, you know it cannot work on linux or windows. I want to run my app on linux or windows. How can I do that?
In short, you package for each platform. As you are aware mac apps do not run on Windows and it is the same with TideSDK since you are creating something native for each platform.
TideSDK must be installed on each platform to create an executable and bundle for it.
To generate an installer for each system, you need to run commands on each system (windows / linux 32bit / linux 64bit) using tidebuilder.py on the command line.
We will have more to speak about concerning packaging quite soon that will make the task of building and distributing your apps easier. Stay tuned for updates !!

Appserv and node.js

I have successfully compiled node.js using cygwin on windows.
The problem is that my environment is set up with Appserv.
Is there a way to compile node.js so that it can be used as an executable outside of cygwin?
See this and this - currently there is no native non-cygwin version.

Resources