Add jsdbg command for debugging Node.js from any terminal
Users can now run jsdbg <command> in any terminal to start a debug session, eliminating the need to manually create and switch to a JavaScript Debug Terminal.
Implementation
-
src/ui/jsdbgCommand.ts: Listens forjsdbgcommands viaonDidStartTerminalShellExecutionand creates a JavaScript Debug Terminal with the extracted command, preserving the original terminal's working directory. -
src/extension.ts: Registers the jsdbg handler on activation.
Usage
# Before: switch to debug terminal, re-navigate
jsdbg node myScript.js
# Also works with npm, yarn, etc.
jsdbg npm start
jsdbg yarn test
The command reuses the existing CreateDebuggerTerminal infrastructure. Requires shell integration to be enabled in VS Code (default for most shells).
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com
- Triggering command:
/usr/lib/apt/methods/https(dns block)plugins.dprint.dev
- Triggering command:
/home/REDACTED/work/vscode-js-debug/vscode-js-debug/node_modules/dprint/dprint fmt OPTIONS.md(dns block)- Triggering command:
/home/REDACTED/work/vscode-js-debug/vscode-js-debug/node_modules/dprint/dprint check(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)
Original prompt
This section details on the original issue you should resolve
<issue_title>Allow debugging a nodejs from a non-"JavaScript Debug Terminal" via
jsdbgcommand</issue_title> <issue_description>It would be awesome if some kind ofjsdbgwould allow me to debug nodejs apps in a standard terminal.My current flow is:
cd myDir(in a standard terminal)node myScript.js- -> crashes
- Create and switch to a new javascript debug terminal
cd myDirnode myScript.js- Happy debugging with VS Code debugger
- Close debug terminal
- Continue with normal terminal
I'd be very happy if the flow was this:
cd myDir(in a standard terminal)node myScript.js- -> crashes
jsdbg node myScript.js- Happy debugging with VS Code debugger
- Continue with normal terminal</issue_description>
<agent_instructions>There is already
copilot-debug. Can you follow that approach to createjsdbgthat immediately attaches to the nodejs process, like the js debug terminal does?</agent_instructions>Comments on the Issue (you are @copilot in this section)
- Fixes microsoft/vscode-js-debug#2291
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.