-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
global module/package resolution problem for ESM #49670
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
Comments
That seems to be an issue with a different project (NPM), not Node.js. FYI NPM development is happening at https://github.com/npm/cli. |
Thanx for the quick response @aduh95! Although NPM is not the same project as Node.js, it is hard to see the point having different conventions. If NPM can find global modules, why can't Node.js? |
@cyberphone apologies, I read past that. This limitation is documented in the docs: https://nodejs.org/api/esm.html#esm_no_node_path |
Thanx @aduh95 ! It was the error message put me on the wrong track since it shows that the associated |
Version
v18.17.1
Platform
Linux ubuntu 5.15.0-83-generic #92-Ubuntu SMP Mon Aug 14 09:30:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
"added 2 packages in 3s"
├── [email protected]
├── [email protected]
└── [email protected]
node:internal/process/esm_loader:97
internalBinding('errors').triggerUncaughtException(
throw err;
^
Error: Cannot find module 'cbor-object'
Require stack:
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:121:18)
at Object. (/home/demo/cbor-test/test.js:2:14)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/demo/cbor-test/test.js' ]
}
comment: this is rather strange given that
npm
found the module. Continued...Now it worked! Continued...
node:internal/process/esm_loader:97
internalBinding('errors').triggerUncaughtException(
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'cbor-object' imported from /home/demo/cbor-test/test.mjs
Did you mean to import cbor-object/cjs/index.cjs?
at new NodeError (node:internal/errors:405:5)
at packageResolve (node:internal/modules/esm/resolve:887:9)
at moduleResolve (node:internal/modules/esm/resolve:936:20)
at defaultResolve (node:internal/modules/esm/resolve:1129:11)
at nextResolve (node:internal/modules/esm/loader:163:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:835:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
at ModuleWrap. (node:internal/modules/esm/module_job:77:40)
at link (node:internal/modules/esm/module_job:76:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
comment: Node has obviously found the module since it refers to
cbor-object/cjs/index.cjs
which is a part of the associatedpackage.json
file:comment: although
npm link cbor-object
works, it defeats the value of global installations.How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
Global should (IMO) not require any specific actions
What do you see instead?
Global package/module resolution working as for npm
Additional information
Gives identical results on W11
The text was updated successfully, but these errors were encountered: