Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have my own server where I uploaded app installer via FTP. Its name is
quickmargo Setup 1.0.0.exe
and it's available at
https://quickmargo.pl/dist/download/quickmargo
Setup 1.0.0.exe
Also via FTP I uploaded
latest.yml
to same directory and it is available at
https://quickmargo.pl/dist/download/latest.yml
In my project in index.js I have
import { autoUpdater } from 'electron-updater'
autoUpdater.setFeedURL('https://quickmargo.pl/dist/download');
autoUpdater.on('update-downloaded', () => {
autoUpdater.quitAndInstall()
autoUpdater.on('update-available', (ev, info) => {
alert('Update required!');
app.on('ready', async () => {
if (process.env.NODE_ENV === 'production') {
await autoUpdater.checkForUpdates()
In package.json I have "version": "1.0.0",
and inside build:{}
I have:
"win": {
"icon": "build/icons/icon.ico",
"publish": [{
"provider": "generic",
"url": "https://quickmargo.pl/dist/download"
( I don't care about other platforms )
Now let's say I've made some changes in my app and I want to upload version 1.0.1 and I want my app to auto update if someone already downloaded installer and installed my app on his machine.
Tell me please if everything what I made so far is fine and what is next step. I consider following:
change version
to 1.0.1
in package.json
run build command in terminal again
upload manually new installer to same place at my server
I did above three steps plus I also uploaded new latest.yml ( with version 1.0.1 ) and result is that when I now run previously installed (before uploading new version to server) version 1.0.0 on other PC then it doesn't detect that I added 1.0.1 to server and it doesn't update or show some popup or anything. What I'm doing wrong?
Edit 2
I'm trying to solve it on my own and now I uploaded 1.0.2 so now link to download app is:
https://quickmargo.pl/dist/download/quickmargo Setup 1.0.2.exe
Edit 3
I was trying to solve it on my own I edited code in index.js. I edited also above. alert('Update required!');
on update-available
event never occure. It should show me error message window that alert is undefined. But apparently update-available event is never emitted.
Additional info:
My app was generated with vue-electron v1.0.6
boilerplate.
My electron-updater version is 4.1.2
npm run build
actually invoke some code from boilerplate which is in .electron-vue/build.js
you can see this file in above link (for example it set NODE_ENV to production. Script in package.json is: "build": "node .electron-vue/build.js && electron-builder",
.
I don't want to host releases at github because my repository is private and I saw some information in electron.build docs that I shoudn't do that.
I also saw info in some issue that I could create new repo only for releases but I consider hosting everything at my own server as more clean approach.
–
–
–
–
I was able to set up an auto update configuration using a generic
publish option following the docs, having never done it before. So it's definitively doable, and it does not require signing via a certificate, but I initially had issues because I had set publisherName
in the build config, but no certificate. If the current version had a publisher or certificate specified, and the new one does not, it will also not be installed.
1. Enable logging
You can enable logging of the electron-updater
package by also installing electron-log
and then assigning the logger to the autoUpdater
:
const log = require('electron-log');
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = 'info';
The default output paths are:
Linux: ~/.config/<app name>/log.log
macOS: ~/Library/Logs/<app name>/log.log
Windows: %USERPROFILE%\AppData\Roaming\<app name>\log.log
If the following steps don't solve your issues, please post the log contents.
2. Don't call autoUpdater.setFeedURL()
The official docs state:
Do not call setFeedURL. electron-builder automatically creates app-update.yml
file for you on build in the resources
(this file is internal, you don’t need to be aware of it).
The URL is already defined in your publish
provider object and that's enough for the updater to work with. Also, a URL string as argument of setFeedURL()
is incorrect, it should be an options object. But again, specifying everything in your publish
provider is sufficient.
3. Also upload the .blockmap
files to your server
These should be created upon build in addition to your setup .exe
files. Otherwise, you will see errors in your log that the files of the old and new version could not be found for comparison.
4. Add a trailing slash to your update server URL
Make sure that the url
parameter of your provider object ends with a slash. While the yml file may still be found without it, there can be issues during the actual download otherwise.
5. Try the simpler approach using autoUpdater.checkForUpdatesAndNotify()
Instead of using the more flexible, but also more complicated way listening to the different update events and reacting to them within your app, try to get it to work with the following code first. Once that works, you can still go back to handling the different events for a better user experience.
app.on('ready', async () => {
autoUpdater.checkForUpdatesAndNotify();
This will check for and download the update in the background and automatically install it as soon as you close your app. A default Windows notification will pop up to inform you about the available update and the procedure.
–
–
–
–
–
I would like to introduce https://github.com/electron-delta/electron-delta-updater here.
It uses the binary diffing approach to generate very small delta files to update your app instead of the older blockmap approach.
npm install @electron-delta/updater
const DeltaUpdater = require("@electron-delta/updater");
const { app, BrowserWindow } = require("electron");
app.whenReady().then(async () => {
const deltaUpdater = new DeltaUpdater({
logger: require('electron-log'),
// optionally set the autoUpdater from electron-updater
autoUpdater: require("electron-updater").autoUpdater,
// Where delta.json is hosted, for github provider it's not required to set the hostURL
hostURL: "https://example.com/updates/windows/",
try {
await deltaUpdater.boot();
} catch (error) {
logger.error(error);
// create main app window after the deltaUpdater.boot()
createMainWindow();
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.