使用 Dockerized 节点进程时,已为某些文件设置断点但尚未绑定

Breakpoint set but not yet bound for some files when using a Dockerized node process

我在 docker 容器中有一个服务器 运行,它在端口 9229 上侦听调试器。下面是我的 launch.json 的样子

{
      "name": "Docker: Attach to Node",
      "type": "node",
      "request": "attach",
      "restart": true,
      "port": 9229,
      "address": "localhost",
      "localRoot": "${workspaceFolder}",
      "remoteRoot": "/app/",
      "protocol": "inspector",
      "skipFiles": [
        "<node_internals>/**"
      ]
    }

在主应用程序文件夹中,我有 3 个子文件夹,如下所示,

/app/api/v1

/app/tests/specs/

/app/utils/

我在所有这三个子文件夹的多个文件中设置了断点,但 vs 代码仅识别为 /app/api/v1 文件夹设置的断点。对于其余文件夹中设置的断点,它显示“已设置断点但尚未绑定”。有人可以帮忙吗?我确实在堆栈溢出中遇到了类似的问题,但 none 帮助了他们。

我按照以下步骤解决了这个问题。

  1. 从 VS Code 市场安装 Docker 扩展。

  1. 单击 Docker 图标,然后右键单击具有节点服务器 运行 和 select“附加到 VS 代码”的容器。

3。在您的 launch.json

中添加以下配置
    {
      "name": "Docker: Attach to container",
      "type": "node",
      "request": "attach",
      "restart": true,
      "port": 9229,
      "address": "localhost",
      "localRoot": "${workspaceFolder}",
      "remoteRoot": "/app",
      "sourceMaps": true,
      "cwd":"${workspaceFolder}",
      "protocol": "inspector",
      "skipFiles": [
        "<node_internals>/**"
      ],
    }
  1. 单击 运行 和调试,然后从下拉列表中单击 select“Docker:附加到容器”。应该附上调试器。