Open privatenumber opened 1 month ago
require()
calls with relative path are still processed by the CommonJS loader
That's not correct, they are processed by your custom loader. If you tweak your resolve
hook to not call the next
function when it receives ./relative
, you won't see the error. The reason you won't see the console.log
output every time is documented here: https://github.com/nodejs/node/blob/fac55e3ef99262877b40a1df461f0e5b94069b28/doc/api/module.md#L391-L394
AFAICT, working as expected, so closing. Let me know if I missed something.
Actually, you were correct, the stack trace shows MODULE_NOT_FOUND
, not ERR_MODULE_NOT_FOUND
, which is an indication that the error is indeed returned by the CJS loader, sorry for answering too quickly.
/cc @nodejs/loaders
Version
v22.2.0
Platform
Darwin mac.local 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:49 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6020 arm64
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Consistently
What is the expected behavior? Why is that the expected behavior?
The
load
hook doc says:https://nodejs.org/api/module.html#resolvespecifier-context-nextresolve:~:text=When%20a%20source,will%20not%20apply.
What do you see instead?
require()
calls with relative path are still processed by the CommonJS loaderAdditional information
No response