10

I use WSL to start VSCode with code . from my project directory in Windows Terminal. When VSCode starts up, "Auto Attach: Off" is shown in the status bar:

enter image description here

Clicking "Auto Attach: Off" in the status bar does not toggle it.

I then start my project in VSCode's integrated terminal with npm run debug, which corresponds to the following scripts line in package.json:

"scripts": {
  "debug": "NODE_ENV=development DEBUG='knex:*' nodemon --inspect ./server.js"
}

However, the debugger is not auto-attached, so I need to manually run the Attach configuration from the Run panel shown on the left here:

enter image description here

The debugger works, but I still cannot toggle the Auto Attach: Off to be On instead:

enter image description here

Even if I Ctrl+Shift+P --> Debug: Toggle Auto Attach, nothing happens. Even if I restart VSCode after doing so.


So, in conclusion, how can I start my VSCode with code . from Windows Terminal and then just type npm run debug and have VSCode, run my program AND auto-attach the debugger? I also need the server to restart upon file changes, which is why I am using nodedemon in the npm run debug script.

Do I need to either:

  • change launch.json configuration? Though I have tried essentially all of the boilerplate launch.json configs shown in VSCode, but none worked.

  • or modify my package.json defined script for debug?

  • or correct some setting on VSCode?

Raj
  • 1,555
  • 18
  • 32
  • you got the solution? – Sunil Garg Feb 11 '21 at 09:54
  • 1
    @SunilGarg I filed a bug report in the github issue tracker https://github.com/microsoft/vscode/issues/102240 and the issue was resolved on their end in one of their subsequent VSCode updates. So everything works fine now without me having to have done anything. After updating to the recent version of VSCode, you may have to toggle Auto-attach off/on in the settings (restarting VSCode in between each toggle). – Raj Feb 15 '21 at 05:47
  • i cant even find the auto attach setting in the settings json autocomplete... – Daniel Lizik Mar 16 '23 at 09:13

0 Answers0