簡體   English   中英

Visual Studio Code 無法調試 Electron

[英]Visual Studio Code unable to debug Electron

我在 Windows 8 上的 Visual Studio Code 上使用 Electron。我是 Electron 的新手。
在使用 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 中調試此代碼

它表明這是一個全局問題,已在 VS Code 的新更新 1.17.2 中修復。 所以我不知道為什么有些人降級了這個問題,盡管它是一個相關的問題,為什么 stackoverflow 允許這樣做,但是對於所有遇到這個問題的人,我發布了這個答案。
安裝新更新 1.17.2 后,問題得到解決。 VS Code 在 1.17 版中解決了這個問題。 以下是有關功能和錯誤修復的一些信息(包括 VS Code 中的電子功能)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM