-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
require
throws, but require.resolve
does not
#43274
Comments
cc @nodejs/modules |
Note: this also seems to be the case in node 14, but not 18. (update: in |
require('node:readline/promises')
fails in node 16, but require.resolve
does notrequire
fails in node 14 and 16, but require.resolve
does not
I'm able to reproduce on both v18.x and $ node -pe 'require.resolve("node:readline/promises2")'
node:readline/promises2
$ out/Release/node -pe 'require.resolve("node:readline/promises2")'
node:readline/promises2
$ out/Release/node -pe 'require("node:readline/promises2")'
node:internal/modules/cjs/loader:790
throw new ERR_UNKNOWN_BUILTIN_MODULE(filename);
^
Error [ERR_UNKNOWN_BUILTIN_MODULE]: No such built-in module: node:readline/promises2
at new NodeError (node:internal/errors:388:5)
at Module._load (node:internal/modules/cjs/loader:790:13)
at Module.require (node:internal/modules/cjs/loader:1008:19)
at require (node:internal/modules/cjs/helpers:102:18)
at [eval]:1:1
at Script.runInThisContext (node:vm:129:12)
at Object.runInThisContext (node:vm:305:38)
at node:internal/process/execution:76:19
at [eval]-wrapper:6:22
at evalScript (node:internal/process/execution:75:60) {
code: 'ERR_UNKNOWN_BUILTIN_MODULE'
}
Node.js v19.0.0-pre |
require
fails in node 14 and 16, but require.resolve
does notrequire
throws, but require.resolve
does not
oh hm, thanks for confirming. the Either way, this feels like a sizable bug with the |
Fixes: #43274 PR-URL: #43336 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Fixes: #43274 PR-URL: #43336 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Fixes: #43274 PR-URL: #43336 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Fixes: nodejs/node#43274 PR-URL: nodejs/node#43336 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Fixes: nodejs/node#43274 PR-URL: nodejs/node#43336 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Version
16.15.0
Platform
Darwin computername.local 20.6.0 Darwin Kernel Version 20.6.0: Wed Jan 12 22:22:42 PST 2022; root:xnu-7195.141.19~2/RELEASE_X86_64 x86_64
Subsystem
node:readline/promises
What steps will reproduce the bug?
node -pe "require.resolve('readline/promises2')"
andnode -pe "require('readline/promises2')"
. Observe that both throw.node -pe "require('node:readline/promises')"
. Observe that it throws "no such builtin module".node -pe "require.resolve('node:readline/promises')"
ornode -pe "require.resolve('node:readline/promises2')
, and instead of throwing, both print the given specifier.Modules that are not requireable must NEVER be require.resolveable; that's part of the contract of require.
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior?
No response
What do you see instead?
See above.
Additional information
No response
The text was updated successfully, but these errors were encountered: