Print node.js script stack traces like regular node
blakeembrey opened this issue · 1 comments
blakeembrey commented
Currently when a node.js script throws an error it is caught in the promise and proceeds through the program until console.error(error.message)
. This results in unexpected behaviour for users who want the regular stack trace like node.js. This issue comes from investigation into TypeStrong/ts-node#592 (e.g. npx ts-node a.ts
does not print anything useful).
A possible workaround could be to console.error(error)
which would show the stack (haven't checked how node.js does this internally) and sub-class existing errors in the script so you can switch the behaviour based on where it originated. Or wrapping Module.runMain()
in a try..catch
and doing something with the error there.