Repository navigation
Bug/feature: ts-node should work with NODE_OPTIONS #471
Description
Activity
- changed the title
[-]How to launch in debug mode[/-][+]Support Q: How to launch in debug mode[/+]on Dec 3, 2017 - changed the title
[-]Support Q: How to launch in debug mode[/-][+]Bug/feature: ts-node should work with NODE_OPTIONS[/+]on Dec 4, 2017 See this issue for reference: nodejs/help#1007
I think the best option would be to wrap or convert https://github.com/TypeStrong/ts-node/blob/master/src/bin.ts into a bash/cmd script.
@stelcheck I think the problem is that
ts-nodespawns a child processhttps://github.com/TypeStrong/ts-node/blob/master/src/bin.ts#L53
so what we need is that spawned child process to debug on a different port than the parent process.
Why even spawn a port on the
binprocess? That process should not even react to NODE_OPTIONS; I can't think of a case where you'd want that as a user. This is why I was suggesting to either replace or wrap that file with a bash/sh/cmd file; these do not react to NODE_OPTIONS, and in the case of wrapping, options could then be forwarded the proper way to the spawned child process.dude I am so confused
this is ergonomic
NODE_OPTIONS="--inspect-brk" ts-node foo.tsbut it breaks... try it.
are you suggesting something more ergonomic, or less? Sounds like the latter to me. Perhaps demo the code you are talking about.
Apologies for the confusion.
I am suggesting a way to patch
ts-node's code in a way that should solve your issue. Should we do that, runningNODE_OPTIONS="--inspect-brk"should start working correctly as-is.And please don't call me dude.
Actually, the simplest thing might just be to introduce a
TS_NODE_OPTIONSenvironment variable which would be passed asNODE_OPTIONSto the spawned process. @blakeembrey would that be acceptable to you?- added a commit that references this issue
on Dec 10, 2017 I preemptively created a PR implementing that behavior. @ORESoftware feel free to give it a spin and let me know if this would fix your current issue.
@stelcheck yes I think that's a good idea -
TS_NODE_OPTIONSseems like a good idea to meif you could make that a command line argument as well as an env variable, that'd be nice too, but probably not that important:
ts-node foo.ts --ts-node-options="--inspect-brk --harmony"I really just need one or the other, but both would make me happy too
For now, can you use
ts-node -r ts-node/register? I'm hesitant to go too much further on the different node.js shell spawning tricks in use right now.@blakeembrey - in this case my node.js process is spawning children and I need to debug the children using Node.js exec flags, so it's not just about loading
ts-node/register.- added a commit that references this issue
on Dec 15, 2017 #499 Would allow you to use NODE_OPTIONS off the bat instead of using TS_NODE_OPTIONS
Reacted by Alexander Millscool I am all for anything that werks
Closing with #536 as I won't be supporting the subprocess behaviour anymore.
This works:
ts-node --inspect-brk foo.ts # ❤️but this doesn't
I think it's because
ts-nodestarts a child process, and because of that, we get an "address already in use" error. See the Node.js help issue attached.Just try it for yourself and you will see the problem.