I want to generate a unique .exe
file to execute the app or a .msi
to install the application. How to do that?
You can also try with the electron-boilerplate. Which has 'release' task of gulp and it will create single ready to go executable file for all cross platform. You only need to build application from all three platform to generate particular platform executable.So you don't need to install any third party tool.
To package the electron app as installable or executable. electron-builder
should be the best choice. And it's easy to configure and we can use electron auto-updater too. Here is the example of electron-builder.json
{
"publish": {
// This can be also 's3', 'github'... based on which server you are using for publish
// https://www.electron.build/configuration/publish
"provider": "generic",
// Feed URL but github provider case, other fields will be required. 'repo', 'owner'...
"url": "https://myappserver.com/updates/"
},
"productName": "My App",
"appId": "com.myapp.app",
"directories": {
// The icon and background in 'buildResources' will be used as app Icon and dmg Background
"buildResources": "buildResources",
// output is directory where the packaged app will be placed
"output": "release"
},
// The files which will be packed
"files": ["src/", "node_modules/", "package.json"],
"mac": {
"target": ["dmg", "zip"], // Also can be, 'pkg', ...
"artifactName": "${productName}-${version}-${os}.${ext}"
},
"win": {
"target": ["nsis", "zip"], // Also can be, 'portable', ...
"artifactName": "${productName}-${version}-${os}.${ext}"
},
"linux": {
"target": ["AppImage"],
"artifactName": "${productName}-${version}-${os}.${ext}"
},
"dmg": {
"title": "${productName}-${version}",
"contents": [
{
"x": 300,
"y": 360
},
{
"x": 490,
"y": 360,
"type": "link",
"path": "/Applications"
}
]
}
}
Of course, we can add other configurations such as nsis
, extraFiles
, afterPack
, afterSign
...
The above are well-used. You can check details and other fields at here https://www.electron.build/configuration/publish
We can define this configuration at the inside of package.json
or as an isolated file but the name should be electron-builder.json
or electron-builder.yml
at the project root directory.
And in addition, for auto-update.
We should upload the installers(dmg, exe, appImage) among with zip
, blockmap
and latest-{OS_Name}.yml
files.
You can package your program using electron-packager and then build a single setup EXE file using InnoSetup.
There are so many good modules which generate single installer *exe file. Check out any of these:
electron-builder (genrates executable for Windows,Mac and Linux, have server-less app auto-update feature,code signing, publishing etc, less boilerplate)
electron-forge (genrates executable for Windows,Mac and Linux, it not just package apps but helps you create them as well, more boilerplate)
windows-installer (easy to use, light weight, and generates only exe file)
(still confused which one to pick? compare here)
I first tried the electron-packager but it produced a lot of .dll files and still could not run.
What did work for me was:
npm install
npm run dist --ia32
This produced a single self contained exe, no other files needed to run the application.
Since most answers dont have step by step instructions on packaging, let me post how i got to package the electron app.
We will be installing electron-packager first.
Electron Packager is a command line tool and Node.js library that bundles Electron-based application source code with a renamed Electron executable and supporting files into folders ready for distribution.
Install electron-packager : run following command in windows cmd
npm install -g electron-packager --save-dev
Next, lets package our app for windowsx64:
electron-packager appdirectory appName --platform=win32 --arch=x64 --electron-version=1.4.3