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:
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:
The debugger works, but I still cannot toggle the Auto Attach: Off
to be On instead:
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 boilerplatelaunch.json
configs shown in VSCode, but none worked.or modify my
package.json
definedscript
fordebug
?or correct some setting on VSCode?