3

Upgrading from Electron v2.0.3 to the latest relase v5.0.1

When I try running electron, I get the following error:

TypeError: app.makeSingleInstance is not a function

I believe this is because the api has changed. I cannot find what the equivalent for this would be. Any help would be appreciated!

main.js (was working fine in v2.0):

    let appInstance= null,
        mainWindow = null,

    appInstance = app.makeSingleInstance(() => {
        if (mainWindow) {
            if (mainWindow.isMinimized()) {
                mainWindow.restore();
            }
            mainWindow.focus();
        }
    })
Kode_12
  • 4,506
  • 11
  • 47
  • 97

1 Answers1

4

Yes, the API has changed since Electron 4.0: Planned Breaking API Changes (4.0):

app.makeSingleInstance

// Deprecated
app.makeSingleInstance((argv, cwd) => {
  /* ... */
})
// Replace with
app.requestSingleInstanceLock()
app.on('second-instance', (event, argv, cwd) => {
  /* ... */
})

More details are available in the documentation for the requestSingleInstanceLock() method and the 'second-instance' event.

Andrew
  • 41
  • 1