如何使用Bun.sh在VSCode中调试JavaScript / Typescript

9

我最近开始尝试使用Bun来运行typescript文件而不需要将它们编译成js。目前为止一切都很好。但是我想在运行时进行调试,但在文档中找不到任何相关信息。

我该如何配置我的.vscode/launch.json文件以使用bun调试项目?

我尝试了一些配置,但没有取得太大进展:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Bun",
            "type": "node",
            "request": "launch",
            "cwd": "${workspaceFolder}",
            "runtimeExecutable": "bun",
            "runtimeArgs": ["run"]
        }
    ]
}

浏览官方路线图,我没有看到关于调试的任何内容,但也许这是一个实验性功能?


3
目前似乎还无法实现这一点。 已经有一个开放的增强请求,要求添加一个运行时调试器 - undefined
我能够通过这里的官方VSCode Bun扩展实现完整的调试:https://marketplace.visualstudio.com/items?itemName=oven.bun-vscode - undefined
1个回答

3
现在可以了。安装第一方扩展
扩展说明显示建议使用launch.json和settings.json来启用"运行文件"命令。
对我来说,我将我的bun安装为devDependancy,开箱即用的扩展无法找到运行时,所以我修改了settings.json如下:
{
    // The path to the `bun` executable.
    "bun.runtime": "node_modules/bun/bin/bun",
    // If support for Bun should be added to the default "JavaScript Debug Terminal".
    "bun.debugTerminal.enabled": true,
    // If the debugger should stop on the first line of the program.
    "bun.debugTerminal.stopOnEntry": false,
}

在那个位置上运行“Bun: Run File”,将能够与调试器一起工作。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接