我在使用 electron 调用 process 函数时候报错,如下:
Uncaught ReferenceError: process is not defined
at index.html:16
可是我已经设置 nodeIntegration =true,仍然不起作用。
我的工具版本:
npm 7.6.1
Electron 13.0.1
Node.js 14.16.0
Chromium 91.0.4472.69
解决方法
webPreferences: { nodeIntegration: true, contextIsolation: false }
参考
Process is not defined for Electron’s Getting Started App [duplicate]
在尝试使用 Electron 的 process 函数时遇到了 'UncaughtReferenceError: process is not defined' 错误,尽管已设置 nodeIntegration 为 true。问题出现在 Electron 版本13.0.1,Node.js 版本14.16.0,Chromium 版本91.0.4472.69。解决方案是通过设置 webPreferences,包括 nodeIntegration 和 contextIsolation 为 false。参考了相关问题解答。
1万+

被折叠的 条评论
为什么被折叠?



