denoland/deno · error
failed to load '{}': {}
Error message
failed to load '{}': {} What it means
During eszip creation, graph.try_get returned an error for the named specifier: the module failed to load or resolve when the graph was built. Static (import statement) failures abort eszip creation; dynamic imports are tolerated and skipped (the function returns Ok(None)).
Source
Thrown at libs/eszip/v2.rs:1377
npm_snapshot: &ValidSerializedNpmResolutionSnapshot,
) -> Result<
Option<Box<dyn DoubleEndedIterator<Item = ToVisit<'a>> + 'a>>,
anyhow::Error,
> {
let module = match graph.try_get(visited.specifier()) {
Ok(Some(module)) => module,
Ok(None) => {
return Err(anyhow::anyhow!(
"module not found {}",
visited.specifier()
));
}
Err(err) => {
if visited.is_dynamic() {
// dynamic imports are allowed to fail
return Ok(None);
}
return Err(anyhow::anyhow!(
"failed to load '{}': {}",
visited.specifier(),
err
));
}
};
let specifier_key =
resolve_specifier_key(module.specifier(), relative_file_base)?;
if modules.contains_key(specifier_key.as_ref()) {
return Ok(None);
}
match module {
deno_graph::Module::Js(module) => {
let source: Arc<[u8]>;
let source_map: Arc<[u8]>;
match module.media_type {View on GitHub (pinned to 89f33cbef2)
Solutions
- Fix the underlying load error for the named specifier (check URL/file availability, run `deno cache --reload`)
- If the module is optional, switch to a dynamic `import()` — eszip skips failing dynamic imports
- Re-run the build once the dependency is reachable again
Example fix
// before — static import of an occasionally unavailable module
import { x } from "https://example.com/flaky/mod.ts";
// after — dynamic import; eszip tolerates its failure
const { x } = await import("https://example.com/flaky/mod.ts"); Defensive patterns
Strategy: try-catch
Validate before calling
# surface load errors before the eszip step deno cache --reload entry.ts && deno compile entry.ts
Try / catch
match build_eszip(graph, npm_packages) {
Err(e) if e.to_string().starts_with("failed to load '") => {
// extract the failing specifier from the message, report it,
// or fall back to a previously built artifact
report_and_fallback(e)
}
result => result?,
} Prevention
- Cache and verify remote dependencies (`deno cache --reload`) before compile/bundle steps
- Use dynamic import() for optional dependencies — eszip tolerates their failure
- Pin remote modules to immutable versioned URLs to avoid 404 drift
When it happens
Trigger: A static import of a module that failed to load — 404 remote URL, unreadable local file, unsupported scheme — while building the eszip/compiled binary.
Common situations: Network failures during `deno compile` of remote dependencies; a file renamed after the graph was cached; importing a URL that now serves an error page.
Related errors
- module not found {}
- unsupported media type {} for {}
- Could not resolve package req '{}' from graph because it was
- BenchContext::start() has already been invoked
- fetch failed
AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16).
Data as JSON: /api/errors/94d04d2627594491.
Report an issue: GitHub.