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

1

71

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.

Overhear answered 15/11, 2016 at 17:15 Comment(2)
Just run: npm install and then npm run dist --ia32Saskatoon
I found the following article to be helpful (using electron-builder): medium.com/how-to-electron/…Fick
A
113

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
Antoniettaantonin answered 15/11, 2016 at 17:17 Comment(8)
I've tried that package, it doesn't work for me. I use an extra module that I installed with the npm install command named "electron-browser-window-options". When using "npm start" my program works fine, but after using electron-packager an error says "Error: Cannot find module 'electron-browser-window-options'".Overhear
Electron packager is the way to go. You should post a new question with your error description. @Praveen: You may want to edit / extend #31287424 instead, this seems to be a duplicate.Glycosuria
@JensHabegger It's gonna be cyclic. 😭Antoniettaantonin
This question was marked as a duplicate but both this question and answer are MUCH better than ones linked to. It's a shame that this answer didn't solve @MitchMitchell's problem but it is the right solution for many people who may not find it if it doesn't have an accepted answer. I think it would be better for the community as a whole if this was rectified.Tusche
@Tusche We tried to talk to the mods and failed about merging the two questions. Unfortunately, that didn't work out.Antoniettaantonin
I'm needing a standalone executable. Currently, electron-packager falls short on this requirement.Thurnau
it just creates a portable folder. is there any way to create a true executable installer i.e. one exe file that actually installs the program to a directory???Upolu
Try electron-builder, see this youtube vid: youtube.com/watch?v=J63H1coQedA.Pyrrhic

© 2022 - 2024 — McMap. All rights reserved.