Electron 无法读取未定义的 属性 getName

Electron cannot read property getName of undefined

我正在按照 http://electron.atom.io/docs/v0.36.5/api/menu/ 上的 Electron 菜单示例进行操作,但是我收到错误

Cannot read property 'getName' of undefined

这发生在 require('electron').app.getName(); 被调用的地方。

当我打开开发工具并查看时,我发现 require('electron') 似乎加载正确,但 require('electron').app returns 未定义。

我假设您在主进程中执行此操作,如果是这样,您可能需要检查是否在某处安装了另一个 electron 模块,如常见问题解答中所述:https://github.com/atom/electron/blob/v0.36.6/docs/faq/electron-faq.md#requireelectronxxx-is-undefined