I struggle to get ts-node-dev to run the underlying node processes with the --inspect flag. Simply running ts-node-dev --inspect my-script.ts doesn't work.
Looking at previous attempt to fix node arguments it might actually be a bug intorduce in https://github.com/whitecolor/ts-node-dev/commit/3ce35a5de5774ff3304fd8c6fda1b5b9d171e0ac#diff-20e1c8ba69ac5634c40dadd70e8da65c. If it is not a bug, what about adding a parameter to the command line to enable inspect (and inspect-brk) on the spawn node process? Could be something like node-inspect and node-inpect-brk? It is a matter of prepending the options to nodeArgs array in.bin/ts-node-dev.
I was able to get the inspector working with ts-node-dev --inspect=127.0.0.1:9229 ./src/index.ts.
@andrewrothman thanks for the insight. It would then mean this is a bug in the way ts-node-dev parses the arguments list.
Interested in getting your thoughts @whitecolor. Happy to help with a PR with whatever you reckon is the right approach.
Interested in getting your thoughts @whitecolor. Happy to help with a PR with whatever you reckon is the right approach.
Unknown flags are treated like string flags by default. The right solution to avoid ambiguity is to separate script name from option flags with --.
ts-node-dev --inspect -- my-script.ts
Will add this in docs. Reopen if something wrong.
Most helpful comment
I was able to get the inspector working with
ts-node-dev --inspect=127.0.0.1:9229 ./src/index.ts.