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