Visual Studio代码无法调试Electron

问题描述:

我在Windows 8上使用Electron on Visual Studio代码。我是Electron的新手。
我使用的是electron-quick-start,它使用VS Code终端运行时,它在Visual Studio Code中工作。但是,当我尝试调试代码,我得到以下错误:Visual Studio代码无法调试Electron

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代码调试代码

+0

正如我所说,它运行时,我终端运行:内部VSCode和外部。问题是当试图用VSCode调试它时 –

+0

你确定你在两个终端上使用相同的命令吗?你在用什么终端? CMD?电源外壳? WSL? – ifconfig

+0

是的。我在Windows 8中使用cmd时,在VS代码外部调用它时,我在VS Code中使用集成终端。对于这两个我使用命令“npm开始”,它在两个工程。当我尝试调试它时出现问题 –

结果表明,这是固定在新的更新一个全球性问题1.17.2 VS代码。所以我不知道为什么有些人降级这个问题,虽然这是一个相关的问题,为什么stackoverflow允许这样做,但对于所有有这个问题的人,我发布这个答案。
安装新的更新1.17.2后,问题得到解决。 VS Code已经在1.17版本中解决了这个问题。 Here是有关功能和错误修复(包括VS代码中的电子功能)的一些信息。