I would need to run ts-node and print stack trace for unhandled promise exceptions.
How to pass an option --trace-warnings?
Feel free to submit a PR. It would need to be added to https://github.com/TypeStrong/ts-node/blob/c57ded2881debf773af7b8e01cb652d48f8655ca/src/bin.ts#L19. This code may be refactored before 4.0 though because of https://github.com/TypeStrong/ts-node/issues/459 and would also result in resolving this.
@bitliner made a PR to add the flag, see https://github.com/TypeStrong/ts-node/pull/476
@stelcheck If you can split out this issue with the other one, I can merge one before the other. Thanks!
Done.
@stelcheck how to use it?
I tried adding script in package.json as
"dev": "ts-node --trace-warnings src/server.tsx",
but i get error when run it
Have a look at https://medium.com/the-node-js-collection/node-options-has-landed-in-8-x-5fba57af703d - this should allow you to define Node.JS flags and options through environment variables.
Doesn't work @stelcheck still getting the error on --trace-warnings
node --trace-warnings -r ts-node/register -r tsconfig-paths/register ./src/index.ts
For future reference, this worked
should I be able to run ts-node --trace-warnings in 2020?
In 2020 specifically, you're supposed to do this: https://github.com/TypeStrong/ts-node/issues/465#issuecomment-659375861
If you find yourself in 2019, you might need to do something else.
In 2020 specifically, you're supposed to do this: #465 (comment)
If you find yourself in 2019, you might need to do something else.
It work, but looks awful. Why can't just add a parameter to the ts-node section in the config?
@Psychosynthesis This has been discussed many times before, but the short of it is: not possible because we don't spawn a subprocess. Doing so adds extra complexity for users and maintainers, and incurs a performance penalty.
Most helpful comment
In 2020 specifically, you're supposed to do this: https://github.com/TypeStrong/ts-node/issues/465#issuecomment-659375861
If you find yourself in 2019, you might need to do something else.