fs.existsSync 在 electron 中使用时不是函数
fs.existsSync is not a function when used in electron
我正在使用 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,
},
我浏览了整个 Whosebug,但找不到任何我未尝试过的解决方案。谁能帮帮我?
所以根据你的句子:
It happens when I import electron and have the following line in my renderer process: import { remote } from 'electron';
在 electron 10 中是遥控器的一个突破性变化 api。
Web 首选项“enableRemoteModule”现在默认为 false。
激活模块并再次测试:
const w = new BrowserWindow({
webPreferences: {
enableRemoteModule: true
}
})
here you find all breaking changes
查看使用 ipcRenderer 的推荐方式:
use ipcRenderer and not remote
我正在使用 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,
},
我浏览了整个 Whosebug,但找不到任何我未尝试过的解决方案。谁能帮帮我?
所以根据你的句子:
It happens when I import electron and have the following line in my renderer process: import { remote } from 'electron';
在 electron 10 中是遥控器的一个突破性变化 api。
Web 首选项“enableRemoteModule”现在默认为 false。
激活模块并再次测试:
const w = new BrowserWindow({
webPreferences: {
enableRemoteModule: true
}
})
here you find all breaking changes
查看使用 ipcRenderer 的推荐方式:
use ipcRenderer and not remote