I have recently started playing with Bun to run typescript files without compiling them to js. So far so good. Eventually I wanted to debug at runtime but couldn't find anything about it in the docs.
How can I configure my .vscode/launch.json file to debug a project using bun?
I tried playing around with a configuration but didn't get very far:
{
"version": "0.2.0",
"configurations": [
{
"name": "Bun",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "bun",
"runtimeArgs": ["run"]
}
]
}
Looking through the official roadmap, I see nothing about debugging, but maybe it is an experimental feature at this point?
It is possible now. Install the 1st party extension.
The extension explainer shows suggests a launch.json and settings.json to enable the command "Bun: Run File".
For me I had my bun installed as a devDependancy, and out-of-the-box the extension could not find the runtime, so I modified the settings.json as follows:
{
// 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,
}
With that in place run "Bun: Run File" would work with the the debugger
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With