简体   繁体   中英

NodeIntegration doesn't work [Electron/js]

I got this error when I tried to enable the integration of Node in Electron:

在此处输入图片说明

If I remove the Node integration, it works again.

function createWindow () {
  // Create the browser window.
  const mainWindow = new BrowserWindow({
    width: 1500,
    height: 800,
    autoHideMenuBar: true,
    webPreferences: {
      nodeIntegration: true,
      preload: path.join(__dirname, 'preload.js')
    }
  })

There is an issue with the Content Security Policy. You can try to set style-src policy with the external styles you are using (such as Bootstrap, FontAwesome and so on).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM