简体   繁体   中英

Visual Studio Code unable to debug Electron

I am using Electron on Visual Studio Code on Windows 8. I am new to Electron.
I used the electron-quick-start which works in Visual Studio Code when running it with the VS Code terminal. 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:

// 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 . That means for 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

It showed that this was a global problem that was fixed in the new update 1.17.2 of VS Code. 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.
After installing the new update 1.17.2 the problem was fixed. VS Code has solved that in version 1.17. Here are some info about the features and bug fixes (including the electron feature in VS Code).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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