Skip to content

Better error message for invalid directory import #33219

@guybedford

Description

@guybedford

The following test case was brought up by @addaleax

esm.mjs:

import mod from './';

console.log(mod);

where node esm.mjs fails with

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension "" for /tmp/test/
    at Loader.defaultGetFormat [as _getFormat] (internal/modules/esm/get_format.js:65:15)

We should ensure the error message here provides the correct steps to resolve the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    esmIssues and PRs related to the ECMAScript Modules implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions