Electron application Can not find Squirrel

Viewed 800

I build an electron app with auto-update enabled. After running the application on Windows, I got an error emitted by my application which is "Error: Can not find Squirrel". After look into the code of electron project for finding the error message.

  checkForUpdates () {
    const url = this.updateURL;
    if (!url) {
      return this.emitError(new Error('Update URL is not set'));
    }
    if (!squirrelUpdate.supported()) {
      return this.emitError(new Error('Can not find Squirrel'));
    }
    this.emit('checking-for-update');
    squirrelUpdate.checkForUpdate(url, (error, update) => {
      if (error != null) {
        return this.emitError(error);
      }
      if (update == null) {
        return this.emit('update-not-available');
      }
      this.updateAvailable = true;
      this.emit('update-available');
      squirrelUpdate.update(url, (error) => {
        if (error != null) {
          return this.emitError(error);
        }
        const { releaseNotes, version } = update;
        // Date is not available on Windows, so fake it.
        const date = new Date();
        this.emit('update-downloaded', {}, releaseNotes, version, date, this.updateURL, () => {
          this.quitAndInstall();
        });
      });
    });
  }

And after check the function squirrelUpdate.supported(). I know it is because the install location has no file "Update.exe".

I use electron-builder to generate my application and there is no Update.exe in unpacked packaged directory. How do I generate the Update.exe file?

The block of configuration of electron-builder in package.json is blow:

       "win": {
            "target": [
                "nsis"
            ],
            "defaultArch": "x64",
            "verifyUpdateCodeSignature": false
        },

How to solve the problem? Thanks.

1 Answers

The reason there is no update.exe is because you have "nsis" as the target package type.

The auto updater package you are trying to use is meant to be compatible with Squirrel.Windows. If you change your target to "squirrel" it will have the update.exe you are looking for.

There are additional dependencies required when using Squirrel.Windows; see below:

https://www.electron.build/configuration/win

Related