const {app, BrowserWindow} = require('electron'); // this is here to keep the window reference alive let win; function create_window() { win = new BrowserWindow({ width: 800, height: 600, webPreferences: { nodeIntegration: true } }) // load the main content win.loadFile('index.html'); win.on('closed', () => { win = null }) } app.on('ready', create_window) // if the window is closed we dereference he object and thus its gc'd // Finally load the window app.on('window-all-closed', () => { if(process.platform !== 'darwin') { app.quit() } }) app.on('activate', () => { if(win === null) { create_window() } })