Ts-node-dev: Add an inspect option to enable debugging

Created on 10 Jul 2018  路  3Comments  路  Source: wclr/ts-node-dev

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.

Most helpful comment

I was able to get the inspector working with ts-node-dev --inspect=127.0.0.1:9229 ./src/index.ts.

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

capc0 picture capc0  路  5Comments

maxpain picture maxpain  路  6Comments

Sytten picture Sytten  路  7Comments

Chnapy picture Chnapy  路  6Comments

DMCTowns picture DMCTowns  路  3Comments