1

What I have Done: I packaged my electron app using electron-builder. I used electron forge typescript & webpack template to create my electron app.

The Error: Cannot find asset "app-setup-21.6.9.exe" in: https://api.github.com/repos/OWNER/REPO/releases/assets/48643890"

I think the problem could be about the location of the build files on when i publish on github ?

MAIN.JS

import { app, BrowserWindow, ipcMain } from 'electron';
import { autoUpdater } from "electron-updater";
const log = require('electron-log');


declare const MAIN_WINDOW_WEBPACK_ENTRY: string;
declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string;



const createWindow = (): void => {
  // Create the browser window.
  const mainWindow = new BrowserWindow({
    height: 650,
    width: 1200,
    webPreferences: {
      preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
    },
  });

  // and load the index.html of the app.
  mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);



  autoUpdater.logger = log;
  log.info('App starting...');
  

  mainWindow.once('ready-to-show', () => {
    autoUpdater.checkForUpdatesAndNotify();

  });

  autoUpdater.on('update-available', () => {
    log.info("update-available");
    mainWindow.webContents.send('update_available');
  });

  autoUpdater.on('error', (ev, err) => {
    mainWindow.webContents.send('error', err);
    log.info(err);
});

autoUpdater.on('download-progress', (ev, progressObj) => {
  mainWindow.webContents.send('download-progress', progressObj);
})

  autoUpdater.on('update-downloaded', () => {
    log.info("update_downloaded");
    mainWindow.webContents.send('update_downloaded');
    autoUpdater.quitAndInstall();
  });


  // returns repos current Version 
  ipcMain.on('app_version', (event) => {

    log.info(app.getVersion());

    mainWindow.webContents.send('app_version', { version: 
    app.getVersion() });
  });


};

Main.js Logs

[info]  App starting...
[info]  Checking for update
[info]  Found version 21.6.9 (url: @cloudreign/app-setup-21.6.9.exe)
[info]  update-available
[info]  Downloading update from @cloudapp/app-setup-21.6.9.exe
[error] Error: Error: Cannot find asset "app-setup-21.6.9.exe" in: https://api.github.com/repos/<OWNER>/<REPO>/releases/assets/48643890"
Ibra
  • 912
  • 1
  • 12
  • 31

3 Answers3

1

In my case I had a productName key in my package.json file that had a different name than the github repo. When I changed it to the same name as the GitHub repo it worked.

Ibra
  • 912
  • 1
  • 12
  • 31
0
autoUpdater.on('update-available', () => {
  log.info("update-available");
  autoUpdater.downloadUpdate() ;
});

You need to add autoUpdater.downloadUpdate() ; to donwload the update.

Abhinay
  • 464
  • 5
  • 13
0

Have you provided GH_TOKEN in publish config in package.json?

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32094594) – Ricardo Dias Morais Jun 29 '22 at 10:12