Skip to content

Better not found errors for ESMΒ #30603

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.

Activity

  1. added
    esmIssues and PRs related to the ECMAScript Modules implementation.
    on Nov 22, 2019
  2. iwnow commented on Nov 24, 2019

    @iwnow

    I have the same issue with ESM "type": "module": extensionless files are not resolved

  3. added
    good first issueIssues that are suitable for first-time contributors.
    help wantedIssues that need assistance from volunteers or PRs that need help to proceed.
    on Nov 25, 2019
  4. juanarbol commented on Nov 26, 2019

    @juanarbol
    Member

    I think I could help with this

  5. juanarbol commented on Nov 28, 2019

    @juanarbol
    Member

    I quite lost with this issue, which Module method should I use? I was trying with Module._resolveFilename, but I'm having troubles with parent, parent url is file://whatever and not an instance of Module

  6. juanarbol commented on Nov 28, 2019

    @juanarbol
    Member

    I need some help D:

    PR #30699

  7. guybedford commented on May 3, 2020

    @guybedford
    ContributorAuthor

    Resolved in #31906 thanks for @dnlup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    esmIssues and PRs related to the ECMAScript Modules implementation.feature requestIssues requesting new Node.js features.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