-
Notifications
You must be signed in to change notification settings - Fork 30.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Erronous import failure message #53806
Comments
Two questions: Does this also occur with require? |
> const odd = require ('is-odd');
Uncaught:
Error: Cannot find module '/app/node_modules/is-odd/index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (node:internal/modules/cjs/loader:482:19)
at Module._findPath (node:internal/modules/cjs/loader:765:18)
at Module._resolveFilename (node:internal/modules/cjs/loader:1205:27)
at Module._load (node:internal/modules/cjs/loader:1045:27)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:215:24)
at Module.require (node:internal/modules/cjs/loader:1304:12)
at require (node:internal/modules/helpers:123:16) {
code: 'MODULE_NOT_FOUND',
path: '/app/node_modules/is-odd/package.json',
requestPath: 'is-odd'
} require works properly. Yep, also occurs in files: root@18f9f8c95d94:/app# node app.mjs
node:internal/modules/esm/resolve:210
const resolvedOption = FSLegacyMainResolve(packageJsonUrlString, packageConfig.main, baseStringified);
^
Error: Cannot find package '/app/node_modules/is-odd/package.json' imported from /app/app.mjs
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)
at ModuleLoader.import (node:internal/modules/esm/loader:483:21) {
code: 'ERR_MODULE_NOT_FOUND'
}
Node.js v22.4.1 |
I'm not able to reproduce |
you need to delete the index.js |
Oh, okay |
+
|
So...does this confirm my description? |
Yup :-) |
@nodejs/loaders |
Note that the message was never precisely correct in ESM. In v20.4.0, the message was:
|
I forgot to translate correctly the path I will try open a PR soon. |
Version
v20.10.0 up to v22.4.1
Platform
Subsystem
No response
What steps will reproduce the bug?
npm install is-odd
node_modules/is-odd/index.js
node
await import("is-odd")
-> Should yield this message:
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 existingpackage.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
The text was updated successfully, but these errors were encountered: