Skip to content

Node does not determine that a file is an ES module when the package.json is in a long path #54304

@BalaM314

Description

@BalaM314

Version

22.6.0

Platform

Microsoft Windows NT 10.0.22631.0 x64

Subsystem

No response

What steps will reproduce the bug?

Create a .js file with the following code:

console.log("Hello world!");
export {};

and a package.json file with the following code:

{
    "type": "module"
}

in a directory with path length greater than 260 characters

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

Node should look at the closest package.json, see "type": "module", determine that the file is an ES module, and run it

What do you see instead?

Node is unable to read the package.json, defaults to CommonJS, and fails at export {}

Additional information

Showcase

Metadata

Metadata

Assignees

No one assigned

    Labels

    loadersIssues and PRs related to ES module loaders

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions