如何在Visual Studio Code中为多根工作区使用调试启动配置? [英] How can I use a debug launch configuration for multi-root workspaces in Visual Studio Code?

查看:309
本文介绍了如何在Visual Studio Code中为多根工作区使用调试启动配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

多根工作区调试似乎没有工作-这些是一项新功能,也许这是一个错误,但是没有实际的示例,只是网站上的伪代码。

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:

VS CODE PROJECTS.code-workspace 文件中:

{
    "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 文件中正常工作。

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.

推荐答案

好吧,简而言之,对我没有任何帮助!
没有启动配置,什么都没有!

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

这是我运行1个调试过程的方式,我将继续讲述如何运行事情也在一起。
Cmd + Shift + P ,键入自动附加以将文件附加到调试器。
然后按 Cmd + J 将终端移到您的特定节点文件夹。
类型: node --inspect。在终端中运行该文件的调试器。

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.

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

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

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

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

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

注意::请确保自动连接处于打开状态。也可以在VS Code屏幕的底部进行切换。

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

这篇关于如何在Visual Studio Code中为多根工作区使用调试启动配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆