Skip to content

ESM package.json in home directory breaks certain programs #54632

@Hacksore

Description

@Hacksore

Version

v20.12.2

Platform

Darwin eloy 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64

Subsystem

No response

What steps will reproduce the bug?

  1. cd to your home directory
  2. npm init -y
  3. add "type": "module" to the new package.json
  4. starting certain apps like Discord and zbirenbaum/copilot.lua will error/crash

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

constantly

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

not to crash other programs?

What do you see instead?

seems those programs like Discord and nvim copilot are traversing up and finding a higher level package.json and panicking at runtime.

Additional information

zbirenbaum/copilot.lua#306
https://x.com/Hacksore/status/1790395583611474423

even got @Jarred-Sumner
https://x.com/jarredsumner/status/1790611334784278853

I'm hoping this issue can solve, "what are developers supposed to do to handle this"?

Is having an ESM package.json in your home directory forbidden by nodejs or is this an edge case that can be patched?

Metadata

Metadata

Assignees

No one assigned

    Labels

    loadersIssues and PRs related to ES module loaderswontfixIssues that will not be fixed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions