Uncaught ReferenceError: require is not defined in Electron BrowserWindow

Uncaught ReferenceError: require is not defined in Electron BrowserWindow

我是 electron js 的新手,我正在尝试使用 devtron。当我在电子浏览器 Window 中使用 require 时。我遇到这个错误

Uncaught ReferenceError: require is not defined

请注意,我在浏览器Window中使用 require 时遇到此错误,而不是在代码中。我也试过在 webPreferences 中设置 nodeIntegration: true,contextIsolation: true。我附上了截图。

这是我的main.js

代码
const {app, BrowserWindow} = require('electron')
const path = require('path')
require('electron-reload')(__dirname);



function createWindow () {
  const mainWindow = new BrowserWindow({
    width: 1000,
    height: 700,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js'),
      nodeIntegration: true,
      contextIsolation: true
    }
  })
  mainWindow.loadFile('index.html')
 }

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

contextIsolation 已启用,禁用 contextIsolationnodeIntegration 应该有效。

webPreferences: {
  nodeIntegration: true,
  contextIsolation: false
}