【问题标题】:Debug electron with vscode. runtimeExecutable用 vscode 调试电子。运行时可执行文件
【发布时间】:2018-01-04 13:11:27
【问题描述】:

我无法使用 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 
    }   
  ]
} 

谢谢。

【问题讨论】:

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


    【解决方案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 
            }   
          ]
        } 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-10
      相关资源
      最近更新 更多