electron require is not defined

解决electron 报错:require is not defined

fixed:设置webpreferences的nodeIntegration的值为true即可

const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js'),
      nodeIntegration:true, // fixed require() is not defined
    }
})

 

你可能感兴趣的:(electron)