From 169ee4118788ef224bd0bd7bd1c7281a28f49617 Mon Sep 17 00:00:00 2001 From: kku Date: Mon, 29 Mar 2021 19:11:01 +0200 Subject: [PATCH] new BrowserWindow requires nodeIntegration=true new BrowserWindow requires nodeIntegration=true, contextIsolation=false as parameters to prevent error thrown in main.html about require() not defined. See https://stackoverflow.com/questions/44391448/electron-require-is-not-defined/55908510 --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 7c61d60..f9c640e 100644 --- a/index.js +++ b/index.js @@ -10,7 +10,10 @@ var knex = require("knex")({ }); app.on("ready", () => { - let mainWindow = new BrowserWindow({ height: 800, width: 800, show: false }) + //https://stackoverflow.com/questions/44391448/electron-require-is-not-defined/55908510 + let mainWindow = new BrowserWindow({ height: 500, width: 800, show: false, webPreferences:{ nodeIntegration: true, + contextIsolation: false,}}) + mainWindow.loadURL(url.format({ pathname: path.join(__dirname, 'main.html'), protocol: 'file',