I'm using electron 2.0.7 and I want to prevent multiple instances of the app by using app.makeSingleInstance.
It works but when i'm trying to run another instance of the app I get this error: "A Javascript error is occurred in the main process" as a pop up.
This is the code in main.ts:
function checkSingleInstance() {
// to make singleton instance
const isSecondInstance = app.makeSingleInstance((commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (win) {
if (win.isMinimized()) {
win.restore();
win.focus();
}
}
});
if (isSecondInstance) {
app.quit();
return;
}
}
checkSingleInstance();
This is the error: