问题
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