Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "Skip checkForUpdatesAndNotify because application is not packed" in electron.js

I'm using "electron-updater" to check for auto-updating Electron application.

Calling "checkForUpdatesAndNotify()" function.

In a console, I get "Skip checkForUpdatesAndNotify because application is not packed".

  • mac0S Mojave,
  • "electron-updater": "^4.0.6",
  • "electron": "^3.0.13",
  • "electron-builder": "20.28.1"

        const {autoUpdater} = require("electron-updater");
        autoUpdater.checkForUpdatesAndNotify();
    
        autoUpdater.on('checking-for-update', () => {
          console.log('Checking for update...');
        });
    
        autoUpdater.on('update-available', (info) => {
          console.log('Update available.');
        });
    
        autoUpdater.on('update-not-available', (info) => {
          console.log('Update not available.');
        });
    
        autoUpdater.on('error', (err) => {
          console.log('Error in auto-updater. ' + err);
        });
    
        autoUpdater.on('download-progress', (progressObj) => {
          let log_message = "Download speed: " + progressObj.bytesPerSecond;
          log_message = log_message + ' - Downloaded ' + progressObj.percent + '%';
          log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')';
          console.log(log_message);
        });
    
        autoUpdater.on('update-downloaded', (info) => {
          console.log('Update downloaded');
        });
    
like image 547
Jovan Avatar asked Jan 11 '19 13:01

Jovan


2 Answers

checkForUpdatesAndNotify() just won't work in development mode.

If you insist on test it in dev mode, you can do some hack with isPackaged:

const app = require('electron').app;

Object.defineProperty(app, 'isPackaged', {
  get() {
    return true;
  }
});

Be careful, do not use this hack for production, it may

like image 72
xcodebuild Avatar answered Oct 20 '22 15:10

xcodebuild


use autoUpdater.checkForUpdates instead

like image 43
B4Le Avatar answered Oct 20 '22 17:10

B4Le