How to debug Deno in VSCode

断了今生、忘了曾经 提交于 2020-06-25 18:02:37

问题


How do we configure .vscode/launch.json to debug Deno projects?

The IntelliSense the VSCode provides when I was in configurations didn't offer an option for Deno. Or is there an extension for this?


回答1:


You need to attach the debugger, as per the deno manual.

Create .vscode/launch.json replacing <entry_point> with your actual script and then F5.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Deno",
            "type": "node",
            "request": "launch",
            "cwd": "${workspaceFolder}",
            "runtimeExecutable": "deno",
            "runtimeArgs": ["run", "--inspect-brk", "-A", "<entry_point>"],
            "port": 9229
        }
    ]
}

It will stop at the breakpoints you set on VS Code, tried here and it worked fine.

About the VS Code plugin:

Official support in plugin is being worked on - https://github.com/denoland/vscode_deno/issues/12




回答2:


to debug current file, you can use below configuration :)

"outputCapture": "std" allows deno to print to VS code console

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

P.S. just added to Evandro Pomatti's answer



来源:https://stackoverflow.com/questions/61853754/how-to-debug-deno-in-vscode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!