1

I'm attempting to implement windows auto update functionality in an electron app (which may lead to my early death) and I'm getting this error.

enter image description here

This is the URL I'm passing for testing purposes

EDIT: my electron app is using the two package.json structure and this code is in my app>main.js file

const feedURL = 'C:\\Users\\p00009970\\Desktop\\update_test';
autoUpdater.setFeedURL(feedURL); 
autoUpdater.checkForUpdates(); 

EDIT2: Thanks to @JuanMa, I was able to get it working. Here is the code.

// auto update functionality

const {autoUpdater} = require('electron')

// local file system example: const feedURL = 'C:\\Users\\john\\Desktop\\updates_folder';
// network file system example: const feedURL = '\\\\serverName\\updates_folder';

const feedURL = '\\\\serverName\\updates_folder';

app.on('ready', () => {
    autoUpdater.setFeedURL(feedURL);

    // auto update event listeners, these are fired as a result of  autoUpdater.checkForUpdates();

    autoUpdater.addListener("update-available", function(event) {

    });
    autoUpdater.addListener("update-downloaded", function(event,   releaseNotes, releaseName, releaseDate, updateURL) {

      //TODO: finess this a tad, as is after a few seconds of launching the app it will close without warning
      // and reopen with the update which could confuse the user and possibly cause loss of work

        autoUpdater.quitAndInstall();
    });
    autoUpdater.addListener("error", function(error) {

    });
    autoUpdater.addListener("checking-for-update", function(event) {

    });
    autoUpdater.addListener("update-not-available", function(event) {

    });

    // tell squirrel to check for updates
    autoUpdater.checkForUpdates();
})
Skedge
  • 89
  • 1
  • 10

1 Answers1

3

Are you including the autoUpdater module correctly?

const {autoUpdater} = require('electron')

If so try to execute the code after the app 'ready' event.

app.on('ready', () => {
  const feedURL = 'C:\\Users\\p00009970\\Desktop\\update_test';
  autoUpdater.setFeedURL(feedURL); 
  autoUpdater.checkForUpdates(); 
})
JuanMa
  • 111
  • 4
  • Including everything in app 'ready' got rid of the error but now I can't tell if it's executing updates or not, I've pushed an update but nothing is happening – Skedge Nov 18 '16 at 18:47
  • Update: app ready definitely fixed my issue, my remaining issue was with corporate proxy crap. I'll update my question with finalized code. – Skedge Nov 18 '16 at 20:13
  • glad I could help! – JuanMa Nov 18 '16 at 21:01