{"id":748,"hash":"84c59a1624680f7e17676af838cecb008a17c7a580fa9b56b7966530a539e497","pattern":"electron 5.0.0 &quot;Uncaught ReferenceError: require is not defined&quot;","full_message":"I had initially been using electron stable (4.x.x), and was able to use require in both my browser and renderer processes. I upgraded to electron beta (5.0.0) because I needed a newer version of node and encountered this error message in my renderer process, Uncaught ReferenceError: require is not defined. \n\nGoogling and looking through the electron docs, I found comments saying the error could be caused by setting webPreferences.nodeIntegration to false when initializing the BrowserWindow; e.g.: new BrowserWindow({width, height, webPreferences: {nodeIntegration: false}});. But I was not doing this, so I thought something else must be the issue and continued searching for a resolution.","ecosystem":"npm","package_name":"node.js","package_version":null,"solution":"For Electron version 12 and above\n\nconst electron = require(\"electron\");\n\nconst { app, BrowserWindow } = electron;\n\napp.on(\"ready\", () => {\n  const mainWindow = new BrowserWindow({\n    width: 1000,\n    height: 600,\n    webPreferences: {\n      nodeIntegration: true,\n      contextIsolation: false,\n      enableRemoteModule: true,\n    },\n  });\n  mainWindow.loadURL(`file://${__dirname}/index.html`);\n});","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/55093700/electron-5-0-0-uncaught-referenceerror-require-is-not-defined","votes":85,"created_at":"2026-04-19T04:51:36.205614+00:00","updated_at":"2026-04-19T04:51:36.205614+00:00"}