70

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.

Mitch Mitchell
  • 735
  • 1
  • 7
  • 5
  • Just run: npm install and then npm run dist --ia32 – nivs1978 Dec 19 '18 at 14:48
  • I found the following article to be helpful (using electron-builder): https://medium.com/how-to-electron/a-complete-guide-to-packaging-your-electron-app-1bdc717d739f – jsherk Jan 06 '19 at 17:04

1 Answers1

111

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
Nagama Inamdar
  • 2,851
  • 22
  • 39
  • 48
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
  • 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'". – Mitch Mitchell Nov 15 '16 at 17:26
  • 2
    Electron packager is the way to go. You should post a new question with your error description. @Praveen: You may want to edit / extend http://stackoverflow.com/questions/31286924/how-to-deploy-an-electron-app-as-a-executable-or-installable-in-windows/31287581#31287581 instead, this seems to be a duplicate. – Jens Habegger Nov 16 '16 at 12:30
  • @JensHabegger It's gonna be cyclic. – Praveen Kumar Purushothaman Apr 04 '19 at 11:53
  • 1
    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. – Besworks Jun 07 '19 at 17:40
  • @Besworks We tried to talk to the mods and failed about merging the two questions. Unfortunately, that didn't work out. – Praveen Kumar Purushothaman Jun 08 '19 at 12:40
  • 2
    I'm needing a standalone executable. Currently, electron-packager falls short on this requirement. – Lonnie Best Jul 25 '19 at 12:58
  • 3
    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??? – oldboy Oct 19 '19 at 12:24