Repository navigation
Uncaught error with --experimental-import-meta-resolve #55518
Description
Activity
- addedexperimentalIssues and PRs related to experimental features.Issues and PRs related to experimental features.confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.
on Oct 24, 2024 The assertion is failing because it expects the URL's protocol to be
file:, when it ishttp:I would like to work on this. In the function
moduleResolvein lib/internal/modules/esm/resolve.js when the protocol of the parsed parentURL is notfilethe parentURL is returned. Instead of just returning the parentURL, can we do something like this in the functionmoduleResolve: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.The code sample just demonstrates the different behavior for resolving a bare specifier in
http:context. For other input there is either a result or a catchable error, but in this case the assertion error crashes the node process.Reacted by Aviv KellerThe provided code sample looks like a loader hook. If so,
import.meta.resolve()is not available within loaders.Regardless, it shouldn't crash at the CPP level. It should probably through a module not found error?
- added a commit that references this issue
on Nov 11, 2024 - added a commit that references this issue
on Nov 16, 2024
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