我正在尝试使用VSCode调试我的电子锻造项目(电子主过程,而不是渲染),但到处都是错误的.我安装了包含所有依赖项的electronic-forge包并初始化我的项目.
我按照this指令操作,我的launch.json用于VSCode:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Electron Main",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-forge-vscode-win.cmd",
"cwd": "${workspaceRoot}"
}
]
}
但是当我在VSCode中按F5进行调试时,我得到的属性“runtimeExecutable”不存在,因为electronic-forge是全局安装的,因此node_modules / .bin / dir中没有这样的文件.
然后根据this我更改了“runtimeExecutable”,我的launch.json如下:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Electron Main",
"runtimeExecutable": "electron-forge-vscode-win.cmd",
"cwd": "${workspaceRoot}"
}
]
}
命令行是:
electron-forge-vscode-win.cmd --debug-brk=17423 --nolazy
√ Locating Application
√ Preparing native dependencies
√ Launching Application
但仍然没有发生.我的电子应用程序启动但并没有因为–debug-brk论证而停止.
接下来,我在launch.json中添加了一行:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"name": "Electron Main",
"runtimeExecutable": "electron-forge-vscode-win.cmd",
"protocol": "inspector"
}
]
}
使用此命令行启动:
electron-forge-vscode-win.cmd --inspect=11172 --debug-brk
√ Locating Application
√ Preparing native dependencies
√ Launching Application
注意:11172是随机端口号
现在我收到此错误:无法连接到运行时进程,10000毫秒后超时 – (原因:无法连接到目标:连接ECONNREFUSED 127.0.0.1:11172).
解决方法:
我相信你需要补充一下
“协议” =“遗留”
到你的启动配置.这是假设您正在使用节点版本< 8.x中