有时候写上node的一些代码,比如process上的一些属性会报错提示找不到
这时候需要在窗口开启的时候配置一段,注意配置完之后要重启一下electron

 nodeIntegration: true

main.js示例

  // Create the browser window.
  const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js'),
      nodeIntegration: true
    }
  })
Last modification:May 20, 2020
If you think my article is useful to you, please feel free to appreciate