Debugging 如何在Visual Studio代码中为多个根工作区使用调试启动配置?

Debugging 如何在Visual Studio代码中为多个根工作区使用调试启动配置?,debugging,visual-studio-code,Debugging,Visual Studio Code,从调试似乎不起作用-这些是一个新功能,可能这是一个错误,但没有实际的例子,只是网站上的psudo代码 Attribute 'program' is not absolute ('${workspaceFolder}/node_modules/mocha/bin/_mocha'); consider adding '${workspaceFolder}/' as a prefix to make it absolute. 虽然很明显,它已经有了一条绝对的路径 以下是我使用的确切启动配置: 在VS

从调试似乎不起作用-这些是一个新功能,可能这是一个错误,但没有实际的例子,只是网站上的psudo代码

Attribute 'program' is not absolute ('${workspaceFolder}/node_modules/mocha/bin/_mocha'); consider adding '${workspaceFolder}/' as a prefix to make it absolute.
虽然很明显,它已经有了一条绝对的路径

以下是我使用的确切启动配置:

VS code PROJECTS.code工作区中
文件:

{
    "folders": [
        {
            "path": "workspace-one"
        },
        {
            "path": "workspace-two"
        },
    ],
    "settings": {},
    "launch": {
        "configurations": [
            {
                "type": "node",
                "request": "launch",
                "name": "WS Mocha 1 File",
                "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
                "args": [
                    "--timeout",
                    "999999",
                    "--colors",
                    "${relativeFile}"
                ],
                "stopOnEntry": false,
                "cwd": "${workspaceFolder}",
                "skipFiles": [
                    "${workspaceFolder}/node_modules/**/*.js",
                ]
            }
        ]
    }
}

基本上,我希望在特定的工作区中打开特定的测试进行调试,而不必在每个根工作区中复制启动配置(我有很多根工作区)。此启动配置在子工作区的
.vscode\launch
文件中运行良好。

将以下内容复制到每个工作区的每个.vscode中时,似乎都能正常工作。但这是一种变通办法,而不是解决方案。我认为多根工作区需要更多的工作。调试也很困难,因为每个工作区的断点也会按字母顺序显示,不会按工作区排序,也不会进行筛选以仅显示打开的活动工作区(在工作区中打开文件的工作区)

.vscode/launch.json:

{
    // Use IntelliSense to learn about possible 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": "launch",
                        "name": "WS Mocha",
                        "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
                        "args": [
                          "-u",
                          "tdd",
                          "--timeout",
                          "999999",
                          "--colors",
                          "${workspaceFolder}/test"
                        ],
                        "internalConsoleOptions": "openOnSessionStart",
                        "skipFiles": [
                          "${workspaceFolder}/node_modules/**/*.js",
                        ]
                },
                {
                        "type": "node",
                        "request": "launch",
                        "name": "WS Mocha 1 File",
                        "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
                        "args": [
                          "--timeout",
                          "999999",
                          "--colors",
                          "${relativeFile}"
                        ],
                        "stopOnEntry": false,
                        "cwd": "${workspaceFolder}",
                        "skipFiles": [
                          "${workspaceFolder}/node_modules/**/*.js",
                        ]
                },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}/server/server.js"
        }
    ]
}
这是启动配置所需要的。可以方便地从多根工作空间根目录中的.vscode/settings.json中的所有工作空间中排除文件

{
  "fileheader.Author": "gbishop",
  "fileheader.LastModifiedBy": "gbishop",
  "files.exclude": {
    "*.csv": "explorerExcludedFiles",
    "*.dat": "explorerExcludedFiles",
    "coverage": "explorerExcludedFiles",
    ".build": "explorerExcludedFiles",
    "logs/": "explorerExcludedFiles",
    "reports/*.xml": "explorerExcludedFiles",
    ".nyc_output/": "explorerExcludedFiles"
  }
}

好吧,简单地说,对我来说什么都不管用! 没有启动配置,什么都没有

这就是我运行1调试过程的方式,我将继续讲述如何一起运行。 按
Cmd+Shift+P
,键入“自动附加”打开将文件附加到调试器。 然后按
Cmd+J
为特定节点文件夹取出终端。 在终端中键入:
节点--inspect.
,以运行该文件的调试器

要运行两个调试器,请在VS代码中打开两个终端。其想法是在不同的端口上附加调试器

转到文件夹1,键入
节点--inspect=9229。

转到第二个终端中的文件夹2,键入
节点--inspect=32089。

注意:确保“自动附加”处于启用状态。它也可以在VS代码屏幕的底部进行切换