Ali123
Ali123

Reputation: 797

Electron App is not running after being packaged

I tried packaging a simple ElectronJS app i created using electron-builder and electron-packager which resulted in a file that is not runnable. when i click on the icon of the app, nothing happens, no errors and no running.

App is running fine locally and shows a notificaiton when starting as well as a tray icon.

Here is the full code if anyone wants to have a look:

https://github.com/ali-h2010/Electron-Huawei-Router-Unoffical-Utility

Note that i was able to package other sample apps so the issue most likely in my project only.

Upvotes: 2

Views: 3571

Answers (1)

tpikachu
tpikachu

Reputation: 4854

Please check my comments about why your app is not working even the app has been packaged correctly.

  // This is wrong
  // win.loadFile('Views/index.html')
  // This will be aboluste path after packaging the app.
  // So the app will look from the root directory.
  // Not inside the app.

  win.loadFile(path.join(__dirname, 'Views/index.html'))

  win.on('close', function (event) {
    // event.preventDefault();
    // win.hide();
  })

  win.on('minimize', function (event) {
    event.preventDefault()
    win.hide()
  })


  let AppTray = null;

  // Same error
  // const iconPath = 'Assets/Images/BatteryIcons/UnknownBattery.png')
  // AppTray = new Tray(iconPath);
  // After packaging the app there won't be assets on root directory
  const iconPath = path.join(__dirname, 'Assets/Images/BatteryIcons')
  AppTray = new Tray(path.join(iconPath, 'UnknownBattery.png'));
  ...

I've made full code on your repo and made PR.

Upvotes: 3

Related Questions