You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug/feature: ts-node should work with NODE_OPTIONS #471
I think it's because ts-node starts 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.
Why even spawn a port on the bin process? 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.
I am suggesting a way to patch ts-node's code in a way that should solve your issue. Should we do that, running NODE_OPTIONS="--inspect-brk" should start working correctly as-is.
Actually, the simplest thing might just be to introduce a TS_NODE_OPTIONS environment variable which would be passed as NODE_OPTIONS to the spawned process. @blakeembrey would that be acceptable to you?
@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.
Activity
[-]How to launch in debug mode[/-][+]Support Q: How to launch in debug mode[/+][-]Support Q: How to launch in debug mode[/-][+]Bug/feature: ts-node should work with NODE_OPTIONS[/+]ORESoftware commentedon Dec 5, 2017
See this issue for reference: nodejs/help#1007
stelcheck commentedon Dec 7, 2017
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.
ORESoftware commentedon Dec 9, 2017
@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.
stelcheck commentedon Dec 10, 2017
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.ORESoftware commentedon Dec 10, 2017
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.
stelcheck commentedon Dec 10, 2017
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.
stelcheck commentedon Dec 10, 2017
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?Support trace-warnings flag, TS_NODE_OPTIONS
stelcheck commentedon 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.
ORESoftware commentedon Dec 12, 2017
@stelcheck yes I think that's a good idea -
TS_NODE_OPTIONSseems like a good idea to meORESoftware commentedon Dec 12, 2017
if 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
blakeembrey commentedon Dec 14, 2017
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.ORESoftware commentedon Dec 14, 2017
@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.TS_NODE_OPTIONS
stelcheck commentedon Dec 20, 2017
#499 Would allow you to use NODE_OPTIONS off the bat instead of using TS_NODE_OPTIONS
ORESoftware commentedon Dec 21, 2017
cool I am all for anything that werks
blakeembrey commentedon Feb 19, 2018
Closing with #536 as I won't be supporting the subprocess behaviour anymore.