简体   繁体   English

Visual Studio Code 无法调试 Electron

[英]Visual Studio Code unable to debug Electron

I am using Electron on Visual Studio Code on Windows 8. I am new to Electron.我在 Windows 8 上的 Visual Studio Code 上使用 Electron。我是 Electron 的新手。
I used the electron-quick-start which works in Visual Studio Code when running it with the VS Code terminal.在使用 VS Code 终端运行 Visual Studio Code 时,我使用了电子快速启动 But when I try to debug the code I get the following error:但是当我尝试调试代码时,出现以下错误:

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)

The error occurs when the debugger reaches the following line in main.js:当调试器到达 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)

I exactly use the code in electron-quick-start .我完全使用了electron-quick-start 中的代码。 That means for package.json:这意味着 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"
  }
}

What have I to do to can debug this code in Visual Studio Code我该怎么做才能在 Visual Studio Code 中调试此代码

It showed that this was a global problem that was fixed in the new update 1.17.2 of VS Code.它表明这是一个全局问题,已在 VS Code 的新更新 1.17.2 中修复。 So I don't know why some people have downgraded this question although it was a relevant question and why stackoverflow allows that, but for all the people who have had this problem, I post this answer.所以我不知道为什么有些人降级了这个问题,尽管它是一个相关的问题,为什么 stackoverflow 允许这样做,但是对于所有遇到这个问题的人,我发布了这个答案。
After installing the new update 1.17.2 the problem was fixed.安装新更新 1.17.2 后,问题得到解决。 VS Code has solved that in version 1.17. VS Code 在 1.17 版中解决了这个问题。 Here are some info about the features and bug fixes (including the electron feature in VS Code). 以下是有关功能和错误修复的一些信息(包括 VS Code 中的电子功能)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM