electronelectron-forgesquirrel.windows

Issue with Electron Forge Squirrel Installer - App Opens with Loading GIF, Closes, and Reopens


I've created an Electron app and used the npm run make command, which runs electron-forge make. Everything works fine, but when running the generated installer "Setup.exe" by @electron-forge/maker-squirrel, the application opens simultaneously with a loading GIF. After the GIF finishes loading, both the GIF and the application close and then reopen. I don't want the app to open before the GIF closes, or at least not be visible. Any suggestions on how to handle this behavior?

Dependencies:

  "dependencies": {
    "electron-squirrel-startup": "^1.0.0"
  },
  "devDependencies": {
    "@electron-forge/cli": "^7.2.0",
    "@electron-forge/maker-deb": "^7.2.0",
    "@electron-forge/maker-rpm": "^7.2.0",
    "@electron-forge/maker-squirrel": "^7.2.0",
    "@electron-forge/maker-zip": "^7.2.0",
    "@electron-forge/plugin-auto-unpack-natives": "^7.2.0",
    "electron": "28.0.0",
    "electron-reloader": "^1.2.3"
  }

Scripts

  "scripts": {
    "start": "electron-forge start",
    "package": "electron-forge package",
    "make": "electron-forge make",
    "publish": "electron-forge publish",
    "lint": "echo \"No linting configured\""
  },

I have consulted the following documentation without success:

  1. https://www.electronforge.io/config/makers
  2. https://www.electronforge.io/config/makers/squirrel.windows
  3. https://github.com/electron/windows-installer
  4. https://github.com/Squirrel/Squirrel.Windows/blob/develop/docs/getting-started/2-packaging.md

Solution

  • Adding this code to your main.js should work:

    if (require("electron-squirrel-startup")) {
      app.quit();
    }