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