How to bundle a third party binary with Electron?

核能气质少年 提交于 2019-12-04 06:07:40

There are a couple of options coming to my mind.

  1. Bundle a 3rd party installer w/ your app. This is what I did recently. On the first run I check if the service that I need is installed / running and if not I call the 3rd party installer / start it. When the installer quits I simply app.relaunch() and start consumig it. Of course you'll need installers for each platform you plan to support. And you'll have to figure out ways to check if the software is installed (properly) for each platform.

  2. Bundle binaries w/ you app. Of course you can bundle pretty much anything w/ your electron app. Again, you'll need binaries for each platform you plan to support. And of course they shouldn't be linked to anything that the default user doesn't have on his machine like SDKs and additional headers ...

  3. Less comfy but you can alway add some start-up message or before-download massage telling the user that he needs software xy in order to run your application.

  4. Derivate of 1/2: Download required stuff on demand. For your example this would mean checking the user's OS and arch and then just download the required installers or binaries if available. You could also build the stuff on the user's machine although this probably being the worst/biggest/most complex solution.

  5. Then there's things like https://www.npmjs.com/package/pg - you should always check npm if someone already built what you need ;)

I'd recommend using the great electron-builder which makes bundling stuff w/ your app a piece of cake.

Feel free to comment if you need more intel.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!