【发布时间】:2020-11-25 21:19:39
【问题描述】:
我正在使用Angular 10、Electron 10.0 和electron-builder v22.8.0。
启动我的 Electron 应用程序时,我在控制台中收到以下错误:
fs.existsSync is not a function when used in electron
getElectronPath @ ./node_modules/events/events.js:6
<anonymous> @ ./node_modules/events/events.js:17
./node_modules/electron/index.js @ ./node_modules/events/events.js:19
__webpack_require__ @ ./webpack/bootstrap:79
./src/app/projectview/new/new.component.ts @ ./src/app/projectview/new/new.component.ts:1
[...]
at __webpack_require__ (bootstrap: 79)
这里弹出错误:
当我导入电子并在我的渲染器进程中有以下行时会发生这种情况:
import { remote } from 'electron';
// later on in my component:
remote.dialog.showOpenDialog(...);
nodeIntegration 在创建BrowserWindow 时是true。
[...]
win = new BrowserWindow({
webPreferences: {
webSecurity: false,
nodeIntegrationInWorker: true,
nodeIntegration: true,
allowRunningInsecureContent: (serve) ? true : false,
},
我浏览了整个 StackOverflow,但找不到任何我没有尝试过的解决方案。谁能帮帮我?
【问题讨论】:
-
你能验证你
webpack.config中的目标是electron-renderer吗? -
@JakeHolzinger 然后编译但失败,
Cannot read property 'dialog' of undefined
标签: node.js angular electron fs