问题描述
我正在尝试使用 VSCode 调试我正在运行的节点应用程序.
I am trying to use VSCode to debug a node app I am running.
我在一个单独的终端中启动应用程序,然后使用附加处理配置来连接它.
I launch the app in a separate terminal and then use the attach to process configuration to hook into it.
附加工作正常,我得到一个侧面板,上面写着已加载脚本",其中包含我的项目中的文件.如果我点击其中一个并在那里设置断点,它将正常工作.
The attaching works correctly and I get a side panel that says 'loaded scripts' with the files in my project. If I click on one of those and set breakpoints there it will work correctly.
如果我在通过 VSCode 编辑器打开的文件上设置断点,断点将显示为灰色,当我将鼠标悬停在其上时,它会显示设置了断点但尚未绑定".
If I set a breakpoint on a file I open through the VSCode editor the breakpoint is greyed out and when I hover over it will say 'Breakpoint set but not yet bound'.
如何才能绑定我在代码上设置的断点?
How can I make it so that the breakpoints I set on the code are bound?
推荐答案
在你的启动文件中试试这个配置:
Try this configuration in your launch file:
{
"name": "Attach to Process",
"type": "node",
"protocol": "inspector",
"request": "attach",
"stopOnEntry": false,
"port": 5858,
"localRoot": "${workspaceRoot}",
"remoteRoot": "/somepath/myprojectroot",
"sourceMaps": true
}
确保remoteRoot
是正确的路径,否则不知道去哪里找源文件.
Make sure the remoteRoot
is correct path, otherwise it won't know where to look for the source files.
这篇关于Visual Studio Code - 未命中节点调试器断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!