How can I use a debug launch configuration for multi-root workspaces in Visual Studio Code?

后端 未结 2 1453
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-22 04:06

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.

相关标签:
2条回答
  • 2021-01-22 04:33

    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"
      }
    }
    
    0 讨论(0)
  • 2021-01-22 04:34

    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.

    0 讨论(0)
提交回复
热议问题