【问题标题】:Electron application Can not find Squirrel电子应用找不到松鼠
【发布时间】:2021-10-06 13:44:46
【问题描述】:

我构建了一个启用了自动更新的电子应用程序。在 Windows 上运行应用程序后,我的应用程序发出一个错误,即“错误:找不到松鼠”。 在查看电子项目的代码以找到错误消息后。

  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();
        });
      });
    });
  }

然后检查函数squirrelUpdate.supported()。我知道这是因为安装位置没有文件“Update.exe”。

我使用 electron-builder 生成我的应用程序,解压后的打包目录中没有 Update.exe。如何生成Update.exe文件?

package.json中electron-builder的配置块是吹的:

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

如何解决问题?谢谢。

【问题讨论】:

    标签: electron electron-builder


    【解决方案1】:

    没有update.exe的原因是因为你有“nsis”作为目标包类型。

    您尝试使用的自动更新程序包旨在与Squirrel.Windows 兼容。如果您将目标更改为“松鼠”,它将具有您正在寻找的update.exe

    使用Squirrel.Windows时需要额外的依赖;见下文:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-10-17
      • 2018-07-13
      • 2019-03-29
      • 1970-01-01
      • 2016-12-07
      • 1970-01-01
      • 2018-10-13
      相关资源
      最近更新 更多