【发布时间】:2017-12-11 13:50:59
【问题描述】:
我正在尝试使用 VSCode(电子主进程,而不是渲染)调试我的电子锻造项目,但到处都出现错误。我安装了包含所有依赖项的 electron-forge 包并初始化了我的项目。
我遵循this 的指令,而我的 VSCode 的launch.json 是:
{
"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)。
【问题讨论】:
标签: javascript node.js visual-studio-code electron forge