【问题标题】:Cannot run deno debugger on vscode无法在 vscode 上运行 deno 调试器
【发布时间】:2021-11-27 10:31:43
【问题描述】:

我是最近的 deno 用户。用 node 很久了,改用 deno,很满意。真的很不错

但是,我有一个问题。
每当我尝试调试 deno 文件时,vscode 调试器都会开始运行大约半秒然后停止,什么也没有发生。 它不会冻结或其他任何东西,它只是开始片刻然后停止。

我将其用作启动配置

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Deno1",
            "type": "node",
            "request": "launch",
            "cwd": "${workspaceFolder}",
            "runtimeExecutable": "deno",
            "outputCapture": "std",
            "runtimeArgs": ["run", "--inspect-brk", "-A", "${fileName}"],
            "port": 9229,

        }
    ]
}

我是从 this post 那里拿到的

我应该补充一点,我已经能够调试此文件,但有一天它刚刚开始显示我刚刚描述的这个问题,而(据我所知)我没有任何更改。

我正在尝试调试this file

我该如何解决这个问题?

【问题讨论】:

    标签: debugging visual-studio-code deno


    【解决方案1】:

    要使其工作,您需要将"program" 字段添加到launch.json 并将文件的路径移到那里,这在您链接到的帖子中的this answer 中简要提及。但是你也需要把"port"改成"attachSimplePort"

    {
        "version": "0.2.0",
        "configurations": [
            {
                "request": "launch",
                "name": "Launch Program",
                "type": "node",
                "program": "${workspaceFolder}/tests/grammar.test.ts", 
                "cwd": "${workspaceFolder}",
                "runtimeExecutable": "deno",
                "runtimeArgs": [
                    "run",
                    "--inspect-brk",
                    "--allow-all"
                ],
                "attachSimplePort": 9229,
                "outputCapture": "std",
            }
        ]
    }
    

    要调试应用程序的另一部分,只需更改program 中的路径,例如更改为main.ts 之类的入口点文件。使用--inspect-brk,调试器将首先在程序的第一行中断,然后您可以使用F5 或调试器面板中的继续按钮继续到断点。

    (Deno v1.14)

    【讨论】:

    • 效果很好,谢谢!
    猜你喜欢
    • 2020-08-31
    • 2023-03-24
    • 2021-02-06
    • 1970-01-01
    • 1970-01-01
    • 2019-10-16
    • 1970-01-01
    • 2022-01-18
    • 2020-02-04
    相关资源
    最近更新 更多