Skip to content

Erronous import failure message #53806

Description

@dakhnod

Version

v20.10.0 up to v22.4.1

Platform

Linux dakhnod 6.5.0-10043-tuxedo #47 SMP PREEMPT_DYNAMIC Tue Jun  4 14:29:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

  1. run npm install is-odd
  2. delete node_modules/is-odd/index.js
  3. start node
  4. run await import("is-odd")
    -> Should yield this message:
Uncaught:
Error: Cannot find package '/app/node_modules/is-odd/package.json' imported from /app/repl
    at legacyMainResolve (node:internal/modules/esm/resolve:210:26)
    at packageResolve (node:internal/modules/esm/resolve:829:14)
    at moduleResolve (node:internal/modules/esm/resolve:915:18)
    at defaultResolve (node:internal/modules/esm/resolve:1132:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:526:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:249:38)
    at onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:484:36)
    at TracingChannel.tracePromise (node:diagnostics_channel:337:14) {
  code: 'ERR_MODULE_NOT_FOUND'
}

complaining about not being able to find package.json, although that file exists.
What is really missing is index.js, since we deleted it.

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

always

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

It would help if node reported about the really missing index.js, not the existing package.json

What do you see instead?

Node complains about not being able to find package.json, although that one clearly exists.

Additional information

No response

Activity

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

    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