主进程debugger  方法二

step1:在vscode的launch.json 文件加入以下配置

{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"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": ["."],
"outputCapture": "std"
}
]
}

step2:点击启动

Electron学习笔记(六)—— 调试小技巧【下】主进程调试方法二_悬停

启动成功如下

Electron学习笔记(六)—— 调试小技巧【下】主进程调试方法二_microsoft_02

step3:main.js中设置断点

Electron学习笔记(六)—— 调试小技巧【下】主进程调试方法二_electron_03

step4: 关闭窗口 会定位到断点的地方

Electron学习笔记(六)—— 调试小技巧【下】主进程调试方法二_悬停_04