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?
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?
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
"outputCapture": "std"
for console logs. thanks @Rhonda –
Strew "debug.javascript.usePreview": false
in your settings because github.com/denoland/vscode_deno/issues/… –
Helpful "port"
to "attachSimplePort"
as described elsewhere. –
Sihon "type": "node"
but not "type": "deno"
? Is it that I have to install node before deno to run the debug? –
Galsworthy The official VS Code Deno extension comes with handy debug support starting with v2.3.0.
Screencast from the PR:You can already press F5 to debug the active file without launch.json
(quite useful).
To auto-generate launch.json
with a Deno
entry: Press CTRL+Shift+D (Open debug view) → "create a launch.json file" → Deno
launch.json
Press Add Configuration...
in opened launch.json
(see screencast above).
F5 will now trigger the currently active debug launch action.
launch.json
, change:
{
"type": "pwa-node",
"program": "${file}", // change "program" value to "${file}"
// ...
},
// Inside keybindings.json
{
"key": "ctrl+alt+d",
"command": "workbench.action.debug.selectandstart",
"args": "Start debug task"
},
The shortcut is called "Debug: Select and Start Debugging"
- see also this related post.
To have log output shown in the debug console, I still needed to add "outputCapture": "std"
to the config entry. More infos:
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
I had to replace port
with attachSimplePort
{
"name": "Deno",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": ["run", "--inspect-brk", "-A", "${fileBasename}"],
"outputCapture": "std",
"attachSimplePort": 9229
},
Install the official Deno extension, Then generate a configuration by opening the Run and Debug panel, selecting Create a launch.json file, and choosing the Deno option from the debugger options.
© 2022 - 2025 — McMap. All rights reserved.
"outputCapture": "std"
to see logs in the debug console. – Rhonda