electron-with-sqlite3 icon indicating copy to clipboard operation
electron-with-sqlite3 copied to clipboard

Uncaught ReferenceError: require is not defined at main.html:5

Open iCrashed opened this issue 3 years ago • 2 comments

The line const electron = require("electron");

in the client script is giving me the error

iCrashed avatar Jul 09 '20 11:07 iCrashed

Verify if your BrowserWindow function has the webPreferences value, with a nodeIntegrations: true. It will resolve your problem with the error of require. See more here https://stackoverflow.com/questions/44391448/electron-require-is-not-defined

LuC4SC4S avatar Jul 09 '20 19:07 LuC4SC4S

Try this as @LuC4SC4S said.

  let mainWindow = new BrowserWindow({
    height: 800,
    width: 800,
    show: false,
    webPreferences: {
      nodeIntegration: true,
    },
  });

tgmarinho avatar Jul 23 '20 17:07 tgmarinho