Better not found errors for ESM #30603
Labels
esm
Issues and PRs related to the ECMAScript Modules implementation.
feature request
Issues that request new features to be added to Node.js.
good first issue
Issues that are suitable for first-time contributors.
help wanted
Issues that need assistance from volunteers or PRs that need help to proceed.
When not using a file extension in ESM - eg
import pkg from './path'
we currently just throw a straightforward not found error. As proposed by @MylesBorins in nodejs/modules#443 it would be useful to enhance this error message.Ideally the error message should run the CJS resolver and say "the CJS resolver would have resolved this module to ...". We actually previously had this code path implemented by @bmeck but it seems to have got lost along the way. See the early implementation at https://github.com/nodejs/node/pull/14369/files#diff-3e94629c67625a2547d1507d0a547211R20.
Sorry @bmeck I think I might have dropped this and forgot to add it back when refactoring error codes to be standard. That was bad.
The text was updated successfully, but these errors were encountered: