问题
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