【发布时间】:2017-09-26 16:36:28
【问题描述】:
我在 Windows 8 上的 Visual Studio Code 上使用 Electron。我是 Electron 新手。
我使用了electron-quick-start,它在与 VS Code 终端一起运行时在 Visual Studio Code 中工作。但是当我尝试调试代码时,出现以下错误:
Debugger listening on [::]:46522
e:\Projects\BT\electron-quick-start\main.js:40
app.on('ready', createWindow)
^
TypeError: Cannot read property 'on' of undefined
at Object.<anonymous> (e:\Projects\BT\electron-quick-start\main.js:40:4)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Timeout.Module.runMain [as _onTimeout] (module.js:604:10)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
当调试器到达 main.js 中的以下行时发生错误:
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)
我完全使用electron-quick-start 中的代码。这意味着对于 package.json:
{
"name": "electron-quick-start",
"version": "1.0.0",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron ."
},
"repository": "https://github.com/electron/electron-quick-start",
"keywords": [
"Electron",
"quick",
"start",
"tutorial",
"demo"
],
"author": "GitHub",
"license": "CC0-1.0",
"devDependencies": {
"electron": "~1.6.2"
}
}
我需要做什么才能在 Visual Studio Code 中调试此代码
【问题讨论】:
-
正如我所说,当我使用终端运行它时它确实有效:VSCode 内部和外部。问题是尝试使用 VSCode 进行调试时
-
您确定在两个终端上使用相同的命令吗?你用的是什么终端?命令?电源外壳? WSL?
-
是的。我在 Windows 8 中使用 cmd 在 VS Code 之外调用它,而在 VS Code 中我使用集成终端。对于这两者,我都使用命令“npm start”,它在它们两者中都有效。当我尝试调试时出现问题
-
并且集成终端设置为使用cmd?
-
是的。设置cmd
标签: node.js visual-studio-code electron