DEV Community

Caleb Albritton
Caleb Albritton

Posted on • Originally published at wa9ace.net on

Debugging Deno Projects in VSCode.

Debugging Deno applications inside VS Code is actually pretty straightforward with the right launch config. Use the below .vscode/launch.json config to debug your entire deno application, debug all of your deno tests, run a single test file, or just the specific test case that you have currently selected.

VSCode Debugging Deno

{
  // 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": "Debug Program",
      "runtimeExecutable": "deno",
      "runtimeArgs": [
        "run",
        "--inspect-brk",
        "./src/main.ts"
      ],
      "port": 9229,
      "console": "integratedTerminal"
    },
    {
      "type": "node",
      "request": "launch",
      "name": "Run Tests",
      "runtimeExecutable": "deno",
      "runtimeArgs": [
        "test",
        "--inspect-brk"
      ],
      "port": 9229,
      "console": "integratedTerminal"
    },
    {
      "type": "node",
      "request": "launch",
      "name": "Debug Current Test File",
      "runtimeExecutable": "deno",
      "runtimeArgs": [
        "test",
        "${file}",
        "--inspect-brk"
      ],
      "port": 9229,
      "console": "integratedTerminal"
    },
    {
      "type": "node",
      "request": "launch",
      "name": "Debug Selected Test Case",
      "runtimeExecutable": "deno",
      "runtimeArgs": [
        "test",
        "${file}",
        "--filter",
        "${selectedText}",
        "--inspect-brk"
      ],
      "port": 9229,
      "console": "integratedTerminal"
    }
  ]
}

Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
driky profile image
Cédric Chatelain

you will want to add "--allow-all" to the runtimeArgs you pass to the command. WIthout it anything that need an "--allow-*" flag will need you to customize the script with the specific flag. Of course that could also be a cleaner solution. Each time you have to use a new flag because of new feature you add it the launch.json file.