Skip to content

Better not found errors for ESM #30603

Closed
Closed
@guybedford

Description

@guybedford

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    esmIssues and PRs related to the ECMAScript Modules implementation.feature requestIssues that request new features to be added to Node.js.good first issueIssues that are suitable for first-time contributors.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions