How To Compile An Electron Application To A .exe [duplicate]

妖精的绣舞 提交于 2020-01-30 14:04:13

问题


I've been learning how to create applications in Electron and I need help compiling a simple project to a Windows executable. The program is a clone from this Github repo: https://github.com/electron/electron-quick-start. On the repo readme it shows how to run the program:

# Clone this repository
git clone https://github.com/electron/electron-quick-start
# Go into the repository
cd electron-quick-start
# Install dependencies
npm install
# Run the app
npm start

This works fine, but I can't figure out how to simply compile it. I've looked all over google, you would think that something as simple as deploying an application would be well known information.


回答1:


You need to use Electron Packager.

Install it using:

# for use in npm scripts
npm install electron-packager --save-dev

# for use from cli
npm install electron-packager -g

And package or deploy using:

electron-packager <sourcedir> <appname> --platform=win32 --arch=x86_64

If you would like to keep it with the Electron Installation, see Application Distribution.

Update :

Above command might throw an error

Unsupported arch=x86_64 (string); must be a string matching: ia32, x64, armv7l, arm64, mips64el

Suggested to use one of the options from ia32, x64, armv7l, arm64, mips64el

electron-packager <sourcedir> <appname> --platform=win32 --arch=x64


来源:https://stackoverflow.com/questions/40615837/how-to-compile-an-electron-application-to-a-exe

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