电子锻造错误 - 无法读取未定义的属性"关闭"



我只是通过使用electron-forge和添加React+webpack+typescript指令建立了一个基本的电子反应应用程序,它都工作得很好(我没有添加任何超出基本设置)。它可以很好地编译所有绿色复选框。

然而,当我点击鼠标右上角的x点击关闭按钮时,它关闭了,但给出以下错误:

An unhandled exception has occurred inside Forge:
Cannot read property 'close' of undefined
TypeError: Cannot read property 'close' of undefined
at WebpackPlugin.exitHandler (C:UserscwebbDocumentsWebdevAtlasnode_modules@electron-forgeplugin-webpacksrcWebpackPlugin.ts:83:16)
at ChildProcess.<anonymous> (C:UserscwebbDocumentsWebdevAtlasnode_modules@electron-forgeplugin-webpacksrcWebpackPlugin.ts:171:18)
at ChildProcess.emit (events.js:412:35)
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
C:UserscwebbDocumentsWebdevAtlasnode_modules@electron-forgeplugin-webpackdistWebpackPlugin.js:87
server.close();
^
TypeError: Cannot read property 'close' of undefined
at WebpackPlugin.exitHandler (C:UserscwebbDocumentsWebdevAtlasnode_modules@electron-forgeplugin-webpacksrcWebpackPlugin.ts:83:16)
at process.<anonymous> (C:UserscwebbDocumentsWebdevAtlasnode_modules@electron-forgeplugin-webpacksrcWebpackPlugin.ts:126:40)
at process.emit (events.js:412:35)
at process.emit (C:UserscwebbDocumentsWebdevAtlasnode_modulessource-map-supportsource-map-support.js:516:21)
at processEmit [as emit] (C:UserscwebbDocumentsWebdevAtlasnode_modulessignal-exitindex.js:155:35)
at process.exit (internal/process/per_thread.js:169:15)
at process.<anonymous> (C:UserscwebbDocumentsWebdevAtlasnode_modules@electron-forgeclisrcutilterminate.ts:20:11)
at process.emit (events.js:400:28)
at process.emit (C:UserscwebbDocumentsWebdevAtlasnode_modulessource-map-supportsource-map-support.js:516:21)
at processEmit [as emit] (C:UserscwebbDocumentsWebdevAtlasnode_modulessignal-exitindex.js:161:32)
at process._fatalException (internal/process/execution.js:167:25)

对于如何纠正这个问题有什么建议吗?我在一个gitmemory网站上找到了一个答案,但它只是说"谢谢,它起作用了"。但是没有评论如何解决这个问题。

提前感谢您的帮助。

我今天偶然发现了这个,并在这里找到了一个提示

如果你不希望发生这种情况,你必须绑定电子appwindow-all-closed事件。通常,当所有窗口关闭时,你会使用此事件退出应用程序。下面是main.js的一个示例片段:

const { app } = require('electron')
app.on('window-all-closed', () => {
app.quit() 
})

如果你想让应用程序在你关闭所有窗口后继续运行,你可以删除对app.quit的调用,但要确保保持对window-all-closed的绑定。绑定可以防止抛出异常。

相关内容

最新更新