Electron require() is not defined

As of version 5, the default for nodeIntegration changed from true to false.
You can enable it when creating the Browser Window:

app.on('ready', () => {
    mainWindow = new BrowserWindow({
        webPreferences: {
            nodeIntegration: true,
            contextIsolation: false,
        }
    });
});

Leave a Comment