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 [email protected] and build my app with [email protected].
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

3
  • 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! Commented Aug 16, 2022 at 13:36
  • No, there is no error. I get a message that a new version was found and then nothing happens.
    – JueK3y
    Commented Aug 16, 2022 at 15:37
  • @AlexanderLeithner Tried a bit and now I get the error: "autoUpdater.autoDownload is not a function"
    – JueK3y
    Commented Aug 17, 2022 at 8:30

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.