You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
Since this-does-not-exist does not exist, Node.js should throw a ERR_MODULE_NOT_FOUND error.
Elsewise, Node.js could print a descriptive message about the limitations of data URL modules that they can't import from node_modules or from relative paths.
What do you see instead?
Instead, an ERR_INVALID_URL error is thrown. The error mentions ./package.json, making it feel like an internal error.
node:internal/url:775
this.#updateContext(bindingUrl.parse(input, base));
^
TypeError: Invalid URL
at new URL (node:internal/url:775:36)
at getPackageScopeConfig (node:internal/modules/esm/package_config:29:24)
at packageResolve (node:internal/modules/esm/resolve:798:25)
at moduleResolve (node:internal/modules/esm/resolve:901:20)
at defaultResolve (node:internal/modules/esm/resolve:1121:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
at link (node:internal/modules/esm/module_job:84:36) {
code: 'ERR_INVALID_URL',
input: './package.json',
base: 'data:text/javascript,%0Aimport%20%22this-does-not-exist%22%3B%0A%20%20'
}
Additional information
Relevant document says that bare specifiers only work for built-in modules. It is normal that the import fails. So this issue is only about the error message.
The text was updated successfully, but these errors were encountered:
Chromium: TypeError: Failed to resolve module specifier "this-does-not-exist". Relative references must start with either "/", "./", or "../".
Firefox: TypeError: The specifier “this-does-not-exist” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”.
Safari: TypeError: Module name, 'this-does-not-exist' does not resolve to a valid URL.
Deno: TypeError: Relative import path "this-does-not-exist" not prefixed with / or ./ or ../
This seems to be fixed (tested on v22.8.0 and v23):
node:internal/modules/esm/resolve:904
const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
^
TypeError [ERR_UNSUPPORTED_RESOLVE_REQUEST]: Failed to resolve module specifier "this-does-not-exist" from "data:text/javascript,%0Aimport%20%22this-does-not-exist%22%3B%0A%20%20": Invalid relative URL or base scheme is not hierarchical.
at moduleResolve (node:internal/modules/esm/resolve:904:23)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
... 3 lines matching cause stack trace ...
at ModuleJob._link (node:internal/modules/esm/module_job:126:49) {
code: 'ERR_UNSUPPORTED_RESOLVE_REQUEST',
cause: TypeError: Invalid URL
at new URL (node:internal/url:816:29)
at moduleResolve (node:internal/modules/esm/resolve:901:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:554:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:523:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49) {
code: 'ERR_INVALID_URL',
input: 'this-does-not-exist'
}
}
Node.js v23.0.0-pre
Version
21.5.0
Platform
Linux Lenovo-X13 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
Run this code:
How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
Since
this-does-not-exist
does not exist, Node.js should throw aERR_MODULE_NOT_FOUND
error.Elsewise, Node.js could print a descriptive message about the limitations of data URL modules that they can't import from
node_modules
or from relative paths.What do you see instead?
Instead, an
ERR_INVALID_URL
error is thrown. The error mentions./package.json
, making it feel like an internal error.Additional information
Relevant document says that bare specifiers only work for built-in modules. It is normal that the import fails. So this issue is only about the error message.
The text was updated successfully, but these errors were encountered: