electron-vue升级electron版本为12x版本后报错Uncaught ReferenceError: require is not defined

2,180 阅读1分钟

electron-vue升级为12x版本后代码报错: Uncaught ReferenceError: require is not defined at (index):1 Uncaught ReferenceError: process is not defined at (index):1 Uncaught ReferenceError: module is not defined at renderer.js:1 image.png 解决方案:在main.js中新增配置:contextIsolation: false webPreferences: { nodeIntegration: true,//是否启用节点集成 nodeIntegrationInWorker:true,//是否在Web工作器中启用了Node集成 contextIsolation: false,//electron为12x版本新增此行 devTools:true,//是否开启 DevTools // webSecurity: true//是否禁用同源策略(上线删除) }