When using Visual Studio Code daily, you may use JavaScript Debug Terminal
to debug your Node.js apps. If you do so, one day, you may struggle with the same issue I did some time ago.
Problem
When I tried to run a Node.js application in the Javascript Debug Terminal, I noticed the debugger was not attaching to the process as it used to, regardless of whether breakpoints were set.
The problem was related to the NODE_OPTIONS
I set in my terminal config file—not the fact that I added it, but the way I did it. It turned out that the debugger in VSC uses the special NODE_OPTIONS
environment variable, and overwriting it may lead to unexpected behaviors.
Solution
Instead of overwriting the variable, you should extend it with your options. For example, the config file (.zshrc
in my case) might contain something like this:
- export NODE_OPTIONS="--some-other-option=here"
+ export NODE_OPTIONS="$NODE_OPTIONS --some-other-option=here"
sidenote: This also applies to Cursor!
source: https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_how-can-i-set-nodeoptions
Top comments (0)