Electron Uncaught ReferenceError: require is not defined

在 Electron 12 版本后, contextIsolation 将默认设置为true。

https://www.electronjs.org/zh/docs/latest/breaking-changes#默认更改-contextisolation-默认为-true

// 主进程
new BrowserWindow({
    webPreferences: {
      nodeIntegration: true,
      contextIsolation: false
    },
    useContentSize: true,
     winLoginSize.width,
    height: winLoginSize.height,
    icon: __static + '/icons/icon.png',
    titleBarStyle: "hiddenInset",
    backgroundColor: "white",
    transparent: true,
    frame: false,
    center: true
})

https://www.electronjs.org/zh/docs/latest/tutorial/context-isolation

原文地址:https://www.cnblogs.com/lbx6935/p/15753640.html