How To Compile An Electron Application To A .exe

Mitch Mitchell picture Mitch Mitchell · Nov 15, 2016 · Viewed 81.6k times · Source

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.

Answer

Praveen Kumar Purushothaman picture Praveen Kumar Purushothaman · Nov 15, 2016

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