vscode-js-debug icon indicating copy to clipboard operation
vscode-js-debug copied to clipboard

Add jsdbg command for debugging Node.js from any terminal

Open Copilot opened this issue 3 months ago • 0 comments

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 for jsdbg commands via onDidStartTerminalShellExecution and 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:

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 jsdbg command</issue_title> <issue_description>It would be awesome if some kind of jsdbg would allow me to debug nodejs apps in a standard terminal.

My current flow is:

  1. cd myDir (in a standard terminal)
  2. node myScript.js
  3. -> crashes
  4. Create and switch to a new javascript debug terminal
  5. cd myDir
  6. node myScript.js
  7. Happy debugging with VS Code debugger
  8. Close debug terminal
  9. Continue with normal terminal

I'd be very happy if the flow was this:

  1. cd myDir (in a standard terminal)
  2. node myScript.js
  3. -> crashes
  4. jsdbg node myScript.js
  5. Happy debugging with VS Code debugger
  6. Continue with normal terminal</issue_description>

<agent_instructions>There is already copilot-debug. Can you follow that approach to create jsdbg that 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.

Copilot avatar Nov 12 '25 10:11 Copilot