Electron Forge 错误 - 无法读取未定义的 属性 'close'

Electron Forge Error - cannot read property 'close' of undefined

我刚刚通过使用 electron-forge 并按照说明添加 React+webpack+typescript 设置了一个基本的 electron-react 应用程序,一切都很好(除了基本设置之外我没有添加任何东西)。它与所有绿色复选框都能很好地编译。

但是,当我通过鼠标点击右上角的 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:\Users\cwebb\Documents\Webdev\Atlas\node_modules\@electron-forge\plugin-webpack\src\WebpackPlugin.ts:83:16)
    at ChildProcess.<anonymous> (C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\@electron-forge\plugin-webpack\src\WebpackPlugin.ts:171:18)
    at ChildProcess.emit (events.js:412:35)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\@electron-forge\plugin-webpack\dist\WebpackPlugin.js:87
          server.close();
                 ^

TypeError: Cannot read property 'close' of undefined
    at WebpackPlugin.exitHandler (C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\@electron-forge\plugin-webpack\src\WebpackPlugin.ts:83:16)
    at process.<anonymous> (C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\@electron-forge\plugin-webpack\src\WebpackPlugin.ts:126:40)
    at process.emit (events.js:412:35)
    at process.emit (C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\source-map-support\source-map-support.js:516:21)
    at processEmit [as emit] (C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\signal-exit\index.js:155:35)
    at process.exit (internal/process/per_thread.js:169:15)
    at process.<anonymous> (C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\@electron-forge\cli\src\util\terminate.ts:20:11)
    at process.emit (events.js:400:28)
    at process.emit (C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\source-map-support\source-map-support.js:516:21)
    at processEmit [as emit] (C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\signal-exit\index.js:161:32)
    at process._fatalException (internal/process/execution.js:167:25)

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

预先感谢您的帮助。

我今天刚 运行 进入这个并设法找到了提示 here

如果您不希望这种情况发生,您必须绑定到 Electron appwindow-all-closed 事件。通常,当所有 windows 都关闭时,您会使用此事件退出应用程序。这是来自 main.js:

的示例片段
const { app } = require('electron')
app.on('window-all-closed', () => {
  app.quit() 
})

如果您希望应用程序在关闭所有 windows 后保留 运行,您可以删除对 app.quit 的调用,但请确保保留对 [=12] 的绑定=].拥有绑定可以防止抛出异常。