使用VSCode调试电子锻造应用程序
我正在尝试使用VSCode调试我的电子锻造项目(电子主过程,而不是渲染),但到处都是错误的。我安装了所有依赖项的electron-forge
包并初始化我的项目。
我遵循this指令,我的launch.json
for 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
进行调试时,我得到了Attribute "runtimeExecutable" does not exist
因为全局安装了electron-forge
所以node_modules/.bin/
目录中没有这样的文件。
然后根据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是随机端口号
现在我收到了这个错误:Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:11172)
。
我相信你需要将"protocol"="legacy"
添加到你的启动配置中。这假设您使用的是Node版本<8.x.