Open ph-fritsche opened 1 day ago
The assertion is failing because it expects the URL's protocol to be file:
, when it is http:
I would like to work on this. In the function moduleResolve
in lib/internal/modules/esm/resolve.js when the protocol of the parsed parentURL is not file
the parentURL is returned. Instead of just returning the parentURL, can we do something like this in the function moduleResolve
:
if (resolved.protocol !== 'file:') {
throw new ERR_INVALID_URL_SCHEME(resolved.protocol);
}
No, That wouldn't work. Under the hood, the issue is because it's trying to read the package configuration for the URL, which it can't do. There are cases where a URL can be used, this is not one of them.
The assertion is failing because it expects the URL's protocol to be
file:
, when it ishttp:
According to this, can we then check for the URL protocol in throwIfInvalidParentURL
?
I believe @JakobJingleheimer may know more than I (regarding the package.json reading) (if not, sorry for the ping)
The provided code sample looks like a loader hook. If so, import.meta.resolve()
is not available within loaders.
Version
22.10
Platform
Subsystem
No response
What steps will reproduce the bug?
Run with
--experimental-import-meta-resolve
:How often does it reproduce? Is there a required condition?
Always reproduces
What is the expected behavior? Why is that the expected behavior?
A catchable error that the specifier can't be resolved. This allows to provide a helpful error message that the user should add a custom resolver/loader.
What do you see instead?
Additional information
No response