Version
v20.19.2
Platform
Darwin MacBookPro 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:49 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6000 arm64
Subsystem
No response
What steps will reproduce the bug?
https://github.com/JounQin/test/tree/repro/node_require_resolve_paths
Simply run node test.js
On node 10:
`resolve` npm package: <CWD>/fixtures/bar.js
`require.resolve` built-in function: <CWD>/fixtures/bar.js
How often does it reproduce? Is there a required condition?
Persist
What is the expected behavior? Why is that the expected behavior?
There is a related old issue #29139.
What do you see instead?
On node 12+, of course including Node LTS (20+)
`resolve` npm package: /Users/JounQin/Workspaces/GitHub/test/fixtures/bar.js
node:internal/modules/cjs/loader:1404
throw err;
^
Error: Cannot find module 'bar'
Require stack:
- <CWD>/test.js
at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15)
at Function.resolve (node:internal/modules/helpers:145:19)
at Object.<anonymous> (/Users/JounQin/Workspaces/GitHub/test/test.js:16:11)
at Module._compile (node:internal/modules/cjs/loader:1730:14)
at Object..js (node:internal/modules/cjs/loader:1895:10)
at Module.load (node:internal/modules/cjs/loader:1465:32)
at Function._load (node:internal/modules/cjs/loader:1282:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:171:5) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '<CWD>/test.js' ]
}
Additional information
I believe there is no reports because most projects use http://npmjs.com/resolve instead, and it behaviors same as Node 10-, and I'm trying to remove resolve as dependency, so I just met this issue at un-ts/eslint-plugin-import-x#272 (comment)
cc @cjihrig
Version
v20.19.2
Platform
Subsystem
No response
What steps will reproduce the bug?
https://github.com/JounQin/test/tree/repro/node_require_resolve_paths
Simply run
node test.jsOn node 10:
How often does it reproduce? Is there a required condition?
Persist
What is the expected behavior? Why is that the expected behavior?
There is a related old issue #29139.
What do you see instead?
On node 12+, of course including Node LTS (20+)
Additional information
I believe there is no reports because most projects use http://npmjs.com/resolve instead, and it behaviors same as Node 10-, and I'm trying to remove
resolveas dependency, so I just met this issue at un-ts/eslint-plugin-import-x#272 (comment)cc @cjihrig