nodeIntegration: true not working properly.

So I’ve got this code in my main.js file:

const { app, BrowserWindow } = require('electron')

function createWindow () {
    const win = new BrowserWindow({
        width: 900,
        height: 630,
        webPreferences: {
            nodeIntegration: true,
            nodeIntegrationInWorker: true,
            nodeIntegrationInSubFrames: true,
            javascript: true,
        },
        fullscreen: true
    })

    win.loadFile('index.html')

    win.setMenuBarVisibility(false);
}

app.whenReady().then(createWindow)

app.on('window-all-closed', () => {
    app.quit();
})

app.on('activate', () => {
    if (BrowserWindow.getAllWindows().length === 0) {
        createWindow()
    }
})

This in my index.html file:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Cipollahouse Utilities</title>
    <script src="scripts/indexPage.js"></script>
</head>
<body>

<button onclick="dynTrigger()">Dynmap Tool</button>

</body>
</html>

And this in my indexPage.js file:

function openTool(toolName, options) {
    const { BrowserWindow } = require('electron');

    const win = new BrowserWindow(options);

    win.loadFile(`../utilitypages/${toolName}.html`)
}

function dynTrigger() {
    openTool("dynmaptool", {
        width: 900,
        height: 630,
        webPreferences: {
            nodeIntegration: true
        },
        fullscreenable: false
    })
}

Yet when I click the button on my main html file, it just says Require is not defined
Is this an update I missed? Should I be using an alternative? Or is this a bug?

1 possible answer(s) on “nodeIntegration: true not working properly.