![Electron build app Electron build app](/uploads/1/2/6/4/126454097/149176817.png)
Nov 01, 2016 In order to register our new Electron application as the handler for custom protocol links, we need to make an installer that would register it. I will use the project electron-builder to package the Electron app. First, let us create 'DMG' installer. The settings will be in the 'build' config object inside the package.json file. Oct 24, 2017 Electron makes it easy for developers to release an app simultaneously on Windows, macOS, and Linux, but there are downsides for users. Electron applications are huge, for one thing. Slack, a chat application, takes up 237 MB of hard drive space on my Mac.
Last time we created a dmg installer for macOS. Now it’s time to look at an Electron Windows installer with Electron-winstaller. This tutorial expects you to build the installer on Windows.
This code will be added to the Electron tutorial app on Github. Before going through this tutorial you need to make sure you know how to package your app.
Adding description
Since i haven’t added it before now i needed to add a description of the app in package.json.
Installing package
Run this command in your terminal:
Setting up installer script
![Windows Windows](https://gitee.com/wapznw/aria2desktop/raw/master/screenshot/WX20180408-172938.png)
Create a new file called createinstaller.js in installers/windows/
The interesting thing here is the settings:
- appDirectory: Tells the installer where to look for the packaged app.
- authors: Who created the app.
- noMsi: should we use an msi installer?
- outputDirectory: where should the installer be saved?
- exe: the name of the packaged exe file in the app directory
- setupExe: the name of the installer exe
- setupIcon: the iconf or the installer
You can find a complete list of settings here.
Running this with the following command would create an installer for us in release-builds/windows-installer.
If you get an error complaining about to long path names, have a look at the asar tutorial.
Handling squirrel install events
Now the readme of electron-winstaller tells us to handle squirrel events inside our app. This will help us with the installation and also create shortcuts for us. The script below is copied directly from that readme. I’ve just wrapped it in module.exports so that we can require it from main.js
Start by creating a file called setupEvents.js in the folder installers/
And in main js we’ll require this file at the beginning:
Adding script shortcuts
As we have done with the packager and dmg installer scripts we will add a script shortcut to the Windows installer script in package.json:
Now you can run the following to create a Windows installer:
Signing installer
Electron Build For Windows
The readme of electron-winstaller tells you to sign your installer. Read more about why.