5

Debugging from multi-root-workspaces does not seem to work - these are a new feature, maybe this is a bug, but there are no actual examples, just psudo-code on the website.

Attribute 'program' is not absolute ('${workspaceFolder}/node_modules/mocha/bin/_mocha'); consider adding '${workspaceFolder}/' as a prefix to make it absolute.

Though obviously it already has an absolute path.

Here is the exact launch configuration I am using:

in VS CODE PROJECTS.code-workspace file:

{
    "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",
                ]
            }
        ]
    }
}

Basically I want to open a particular test in a particular workspace for debugging without having to replicate the launch configuration in each root workspace (I have a lot of them). This launch configuration works fine in .vscode\launch file for the sub workspaces.

4 Answers 4

1

This is solved with a compound launch configuration, which is just a reference to a configuration name. I just tested it and works fine: https://code.visualstudio.com/docs/editor/multi-root-workspaces#_workspace-launch-configurations. You will end up with something like this.

"launch": {
        "configurations": [],
        "compounds": [
            {
                "name": "Attach to .NET Functions",
                "configurations": [
                    "Attach to .NET Functions YOUR_UNIQUE_LAUNCH_CONFIG_NAME"
                ]
            }
        ]
    }
0
1

Use ${fileWorkspaceFolder} instead of ${workspaceFolder}.

This will cause the currently opened file to be used to determine which workspace folder to use.

Visual Studio Code - Variables Reference

-1

The following seems to work when copied into each .vscode of each workspace. This is a work around though and not a solution. I think multi-root-workspaces need some more work. Debugging also is also hard because the breakpoints for each workspace are also shown, and in alphabetical order, not sorted per workspace, nor filtered to only show open active workspace (those with files open in the workspace).

.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"
        }
    ]
}

This is what is needed for launch configurations. It is convenient to exclude files from ALL workspaces in a .vscode/settings.json in the multi-root-workspaces root.

{
  "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

Ok so simply put, nothing worked for me ! No launch configs, nothing !

This is how I ran 1 debugging process, I'll proceed to tell how to run things together as well. Press Cmd+Shift+P , type 'auto attach' to switch on attaching files to debugger. Then PRESS Cmd+J to get the terminal out for your specific node folder. Type : node --inspect . in the terminal to run the debugger for that file.

To run two debuggers, open two terminals in VS code. The idea is to attach debuggers on different ports.

Go to folder 1 , type node --inspect=9229 .

Go to folder 2 in 2nd terminal , type node --inspect=32089 .

Note : Make sure auto-attach is On. It can also be toggled on the bottom of the VS Code screen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.