使用vscode调试电子。 runtimeExecutable

时间:2017-07-28 12:46:37

标签: debugging typescript visual-studio-code electron vscode-settings

我无法使用vscode在Windows上调试电子主进程。我已经尝试了所有可能找到的launch.json配置,但app对象始终是undefined。应用程序工作,我只有调试问题。好像我的runtimeExecutable路径错了。我已尝试https://discuss.atom.io/t/debugging-electron-api-demo-using-visual-studio-code/40661/2我从文档https://github.com/electron/electron/blob/master/docs/tutorial/debugging-main-process-vscode.md

中获取了当前配置

我的launch.json

{
  "version": "0.2.0",
  "configurations": [
    { 
      "name": "Debug Main Process",
      "type": "node",
      "request": "launch",
      "program": "${workspaceRoot}/app/main.ts",
      "stopOnEntry": false,
      "args": ["."],  
      "cwd": "${workspaceRoot}",
      "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd",
      "outFiles": [  
        "${workspaceRoot}/dist/main.js"
      ],
      "env": { }, 
      "sourceMaps": true 
    }   
  ]
} 

谢谢。 enter image description here

1 个答案:

答案 0 :(得分:1)

根据文档https://code.visualstudio.com/docs/nodejs/nodejs-debugging Inspector protocol尚不支持电子。

这是有效的配置。应该一直在添加协议遗产。

  {
      "version": "0.2.0",
      "configurations": [
        { 
          "name": "Debug Main Process",
          "type": "node",
          "request": "launch",
          "program": "${workspaceRoot}/app/main.ts",
          "stopOnEntry": false,
          "args": ["."],  
          "cwd": "${workspaceRoot}",
          "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd",
          "outFiles": [  
            "${workspaceRoot}/dist/main.js"
          ],
          "protocol":"legacy",
          "env": { }, 
          "sourceMaps": true 
        }   
      ]
    }