-
Notifications
You must be signed in to change notification settings - Fork 43
Better errors on module not found #443
Comments
It'd be a great way to collect feedback if that message included a URL to file an issue as well :-) |
I was reading #442 and thinking exactly the same thing.
I’ve also never understood why a Node error includes a stack trace with Node’s internals, but I guess that’s a broader nit. |
Potential issues:
A more generic warning would be (if none of the supported extensions is used): “Did you forget a filename extension?” |
@rauschma I agree with your edit "if none of the supported extensions is used". This would allow the missing extension error to appear if someone tries to Not retrying the resolve with node algorithm is beneficial in some edge cases. I'm thinking about babel resolving plugins where someone configures Another case is |
FWIW I was imagining tha twe could scope when this happens, likely around existing If no module was found a generic message, similar to what we currently have, could be used. If they searched in the wrong directory they would likely get the same generic message as above, it would fail in a similar way to how modules not being found in CJS would work. |
Posting here for more visibility: should nodejs/node#31906 be backported to v12.x-staging? I haven't had time to check why, but the tests fail if that PR is applied. |
I can dig in today... we should backport if we can |
looks like it's fixed LOL Closing |
I think it is going to be a fairly common pattern (for a while) that people will expect they can import a file without an extension. When a module is not found
ERR_MODULE_NOT_FOUND
is thrown. The error is thrown inmodule_wrap.cc
within Maybe FinalizeResolutionBefore throwing
ERR_MODULE_NOT_FOUND
we could check with the node resolution algorithm if there is a file that would have resolved with that specifier and let the developer know the path of the expected file.Thoughts?
The text was updated successfully, but these errors were encountered: