如何在 VSCode 中调试 Deno
How to debug Deno in VSCode
我们如何配置 .vscode/launch.json
来调试 Deno 项目?
我在 configurations
时 VSCode 提供的 IntelliSense 没有为 Deno 提供选项。或者有扩展吗?
您需要根据 the deno manual.
附加调试器
创建 .vscode/launch.json
用您的实际脚本替换 <entry_point>
然后 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
}
]
}
它会在你在 VS Code 上设置的断点处停止,在这里试过它工作正常。
关于 VS Code 插件:
Official support in plugin is being worked on -
https://github.com/denoland/vscode_deno/issues/12
调试当前文件,你可以使用下面的配置:)
"outputCapture": "std"
允许 deno 打印到 VS 代码控制台
{
"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。刚刚添加到 Evandro Pomatti 的回答中
官方VS Code Deno extension comes with handy debug support starting with v2.3.0.
来自 PR 的截屏:
新项目
您已经可以按 F5 调试活动文件而无需 launch.json
(非常有用)。
到 auto-generate launch.json
使用 Deno
条目:按 CTRL+Shift+ D(打开调试视图)→“创建一个 launch.json 文件”→Deno
在现有 launch.json
中添加 Deno 条目
在打开的launch.json
中按Add Configuration...
(见上面的截屏视频)。
F5 现在将触发当前活动的调试启动操作。
启动活动文件
要在已配置 launch.json
的情况下调试当前活动文件,请更改:
{
"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"
},
快捷方式称为 "Debug: Select and Start Debugging"
- 另请参阅 。
在调试控制台中启用日志输出
要在调试控制台中显示日志输出,我仍然需要将 "outputCapture": "std"
添加到配置条目。更多信息:
- Where is stdout for VS Code?
- Debug output doesn't appear in debug console without "outputCapture": "std" #41600
相关
我们如何配置 .vscode/launch.json
来调试 Deno 项目?
我在 configurations
时 VSCode 提供的 IntelliSense 没有为 Deno 提供选项。或者有扩展吗?
您需要根据 the deno manual.
附加调试器创建 .vscode/launch.json
用您的实际脚本替换 <entry_point>
然后 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
}
]
}
它会在你在 VS Code 上设置的断点处停止,在这里试过它工作正常。
关于 VS Code 插件:
Official support in plugin is being worked on - https://github.com/denoland/vscode_deno/issues/12
调试当前文件,你可以使用下面的配置:)
"outputCapture": "std"
允许 deno 打印到 VS 代码控制台
{
"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。刚刚添加到 Evandro Pomatti 的回答中
官方VS Code Deno extension comes with handy debug support starting with v2.3.0.
来自 PR 的截屏:新项目
您已经可以按 F5 调试活动文件而无需 launch.json
(非常有用)。
到 auto-generate launch.json
使用 Deno
条目:按 CTRL+Shift+ D(打开调试视图)→“创建一个 launch.json 文件”→Deno
在现有 launch.json
中添加 Deno 条目
在打开的launch.json
中按Add Configuration...
(见上面的截屏视频)。
F5 现在将触发当前活动的调试启动操作。
启动活动文件
要在已配置launch.json
的情况下调试当前活动文件,请更改:
{
"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"
},
快捷方式称为 "Debug: Select and Start Debugging"
- 另请参阅
在调试控制台中启用日志输出
要在调试控制台中显示日志输出,我仍然需要将 "outputCapture": "std"
添加到配置条目。更多信息:
- Where is stdout for VS Code?
- Debug output doesn't appear in debug console without "outputCapture": "std" #41600