-
-
Notifications
You must be signed in to change notification settings - Fork 532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Friendlier error when the .ts file is not found #1357
Comments
What error do you get when you do this without ts-node? |
Node spits out a somewhat shorter message,
|
Ok, we shouldn't shorten the call stack because that would be violating some fundamental expectations for errors. There's a pull request where I attempted a prototype of this, but it's a messy hack. We can improve the error message, though. Should be a straightforward PR for you or anyone else you can convince to do it. :) Below are detailed notes to explain what needs to be done, but again, it's a pretty simple improvement. Don't let the verbosity scare you. Our ESM resolver is copy-pasted straight out of node's own source code. This is the resolver, and it throws The errors, however, are stub implementations: https://github.com/TypeStrong/ts-node/blob/main/dist-raw/node-errors.js So if you or anyone else wants to implement nicer errors, I believe all you need to do is update In our copy-pasted resolver, we've deliberately left node's original require calls commented out so you know where to look in node's source to find the implementations. In this case, the errors were imported from |
I've labelled this "help wanted" to indicate we will await and accept a PR improving our error messages. If you want other people to more easily find this issue, feel free to rename it to something more generic like "improve error messages" or something like that. |
I'd like to work on this. :) |
I mistyped the name of my script, and node spat out an ugly-looking error instead of a simple "Hey dude, file not found":
Would it be possible to simplify this error, or is this completely up to Node?
The text was updated successfully, but these errors were encountered: