How to build your Electron js app as Windows executable for Windows?

I made this post because if I did not work on Elenctron project for some times, I can not remember how I did it that time.

So, let’s say we have a “ready to build” Electron project, to build it for Windows, first let’s install Electron Packager (my favorite method is using Electron Packager). To install it, follow it’s instruction here:

Or simply run this command to install it:

npm install --save-dev electron-packager

Or, if that’s not working, try this:

npm install -D electron-packager 
npx electron-packager .

If you want to install it globally:

npm install -g electron-packager

After installing it, in my case, I would like to run this command to build Windows 64 executable plus adjusting it’s executable icon:

electron-packager ./ YourAppName --platform=win32 --arch=x64 --icon=./icon.ico

The first part is obvious, electron-packager is the program that we run.

Second part, ./ means we are building what we have in current directory. So please note you need to navigate to your index.html directory on your cmd then you can run above command.

–platform=win32 is telling the program to build Windows executable.

Then –arch=64 is my choice to have 64bit program.

The last part –icon=./icon.ico is defining what icon file do I use for my executable. I already prepared .ico file on my working files directory so I point it that way.

Hope it’s useful to you, and to me for sure.


Leave a Reply

Your email address will not be published. Required fields are marked *