您可以执行此操作,但需要进行一些修改。
launch.json
{ // Use IntelliSense to learn about possible Node.js debug attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "node", "request": "attach", "name": "Attach to Remote", "address": "127.0.0.1", "port": 9229, "localRoot": "${workspaceRoot}", "remoteRoot": "/usr/src/app", "preLaunchTask": "start_node_compose" } // { // "type": "node", // "request": "launch", // "name": "Launch Program", // "program": "${workspaceRoot}/index.js" // } ]}如您所见,我评论了本地启动,并使其成为第一个启动程序,因此它可以在F5上运行。接下来,我们需要定义一个
start_node_compose任务
task.json
{ "version": "0.1.0", "command": "myCommand", "isShellCommand": false, "args": [], "showOutput": "always", "tasks": [ { "taskName": "start_node_compose", "showOutput": "always", "isBuildCommand": true, "command": "/bin/bash", "args": [ "-c", "docker-compose -f docker-compose.yml -f docker-compose.debug.yml up -d && sleep 10" ] } ]}Then when you run the command using F5 you will be able to hit the breakpoint



