0

The idea:
electron-updater is supposed to update my electron software automatically when a new version is released.

The problem: electron-updater detects the new version, but does not download and install it. I use electron-updater@4.3.8 and build my app with electron-builder@8.17.0.
Switching to older versions unfortunately did not help either.

Update:
Electron now throws the error autoUpdater.autoDownload is not a function.

Code snippets
Main.js:

    // autoUpdater.checkForUpdatesAndNotify() is called in "mainWindow.on('ready-to-show', ...)

    // ------ AutoUpdater ------ //
    autoUpdater.logger = log;
    autoUpdater.logger.transports.file.level = 'info';

    const sendStatusToWindow = (text) => {
      log.info(text);
      if (mainWindow) {
        mainWindow.webContents.send('update', text)
      }
    }

    autoUpdater.on('checking-for-update', () => {
      sendStatusToWindow('Checking for update...')
    })

    autoUpdater.on('update-available', (info) => {
      sendStatusToWindow('Update available.')
      autoUpdater.autoDownload()
    })

    autoUpdater.on('update-not-available', (info) => {
      sendStatusToWindow('Update not available.')
    })

    autoUpdater.on('error', (err) => {
      log.error(`Update-Error: ${err.toString()}`)
      mainWindow.webContents.send('message', `Error in auto-updater: ${err.toString()}`)
    })

    autoUpdater.on('download-progress', progressObj => {
      sendStatusToWindow(
        `Download speed: ${progressObj.bytesPerSecond} - Downloaded ${progressObj.percent}% (${progressObj.transferred} + '/' + ${progressObj.total} + )`
      )
    })

    autoUpdater.on('update-downloaded', () => {
      sendStatusToWindow('Update downloaded; will install now')
      autoUpdater.quitAndInstall();
    })

Package.json:

    {
      "name": "iac_2",
      "productName": "IAC 2.0",
      "version": "0.8.3-alpha",
      "homepage": "https://github.com/JueK3y/Instagram-automated-commenting",
      "repository": {
        "type": "git",
        "url": "https://github.com/JueK3y/Instagram-automated-commenting"
      },
      "main": "main.js",
      "scripts": {
        "start": "electron .",
        "test": "echo \"Error: no test specified\" && exit 1",
        "pack": "electron-builder --dir",
        "dist": "electron-builder"
      },
      "devDependencies": {
        "electron": "^15.5.7"
      },
      "dependencies": {
        "electron-log": "^4.4.8",
        "electron-updater": "^4.3.8",
        "electron-window-state": "^5.0.3",
        "is-online": "^9.0.1",
        "keytar": "^7.9.0",
        "network-speed": "^2.1.1",
        "node-notifier": "^10.0.1",
        "puppeteer": "^16.0.0",
        "puppeteer-extra": "^3.3.4",
        "puppeteer-extra-plugin-stealth": "^2.11.0"
      },
      "build": {
        "appId": "jue3ky.iac_2.app",
        "productName": "IAC 2.0",
        "copyright": "Copyright © 2022 by JueK3y",
        "win": {
          "target": "nsis",
          "icon": "icon.ico",
          "publish": {
            "provider": "github"
          }
        },
        "asar": true,
        "asarUnpack": "node_modules/puppeteer/.local-chromium/**/*"
      }
    }

Full code is here: https://github.com/JueK3y/Instagram-automated-commenting/tree/main/public

JueK3y
  • 267
  • 9
  • 22
  • When you say that the download fails, are you getting any information on the error whatsoever? If yes, please [edit] your question and include the error message. Thanks! – Alexander Leithner Aug 16 '22 at 13:36
  • No, there is no error. I get a message that a new version was found and then nothing happens. – JueK3y Aug 16 '22 at 15:37
  • @AlexanderLeithner Tried a bit and now I get the error: "autoUpdater.autoDownload is not a function" – JueK3y Aug 17 '22 at 08:30

1 Answers1

0

Deleting autoUpdater.autoDownload() fixed the autoUpdater.autoDownload is not a function error.

The other error, that the update is not downloaded, was related to GitHub for me. There the .exe file was named differently than the .exe.blockmap file, which is why electron-updater returned a 404 error.

JueK3y
  • 267
  • 9
  • 22