How To Compile An Electron Application To A .exe

JavascriptDeploymentWeb DeploymentDesktop ApplicationElectron

Javascript Problem Overview


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.

Javascript Solutions


Solution 1 - Javascript

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMitch MitchellView Question on Stackoverflow
Solution 1 - JavascriptPraveen Kumar PurushothamanView Answer on Stackoverflow