调试VSCode中的主进程 | Debugging the Main Process in VSCode
Debugging the Main Process in VSCode
1.在VSCode中打开一个Electron项目。
$ git clone git@github.com:electron/electron-quick-start.git
$ code electron-quick-start
2.添加.vscode/launch.json具有以下配置的文件:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Main Process",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"args" : ["."]
}
]
}
注意:
对于Windows,"${workspaceRoot}/node_modules/.bin/electron.cmd"
用于runtimeExecutable
。
3.调试
在中设置一些断点main.js
,然后在调试视图中开始调试。你应该能够击中断点。
这是一个预配置的项目,您可以下载并直接在VSCode中调试:https://github.com/octref/vscode-electron-debug/tree/master/electron-quick-start