{"record":{"id":"94d04d2627594491","repo":"denoland/deno","slug":"failed-to-load","errorCode":null,"errorMessage":"failed to load '{}': {}","messagePattern":"failed to load '(.+?)': (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"libs/eszip/v2.rs","lineNumber":1377,"sourceCode":"      npm_snapshot: &ValidSerializedNpmResolutionSnapshot,\n    ) -> Result<\n      Option<Box<dyn DoubleEndedIterator<Item = ToVisit<'a>> + 'a>>,\n      anyhow::Error,\n    > {\n      let module = match graph.try_get(visited.specifier()) {\n        Ok(Some(module)) => module,\n        Ok(None) => {\n          return Err(anyhow::anyhow!(\n            \"module not found {}\",\n            visited.specifier()\n          ));\n        }\n        Err(err) => {\n          if visited.is_dynamic() {\n            // dynamic imports are allowed to fail\n            return Ok(None);\n          }\n          return Err(anyhow::anyhow!(\n            \"failed to load '{}': {}\",\n            visited.specifier(),\n            err\n          ));\n        }\n      };\n\n      let specifier_key =\n        resolve_specifier_key(module.specifier(), relative_file_base)?;\n      if modules.contains_key(specifier_key.as_ref()) {\n        return Ok(None);\n      }\n\n      match module {\n        deno_graph::Module::Js(module) => {\n          let source: Arc<[u8]>;\n          let source_map: Arc<[u8]>;\n          match module.media_type {","sourceCodeStart":1359,"sourceCodeEnd":1395,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/libs/eszip/v2.rs#L1359-L1395","documentation":"During eszip construction, graph.try_get(specifier) can also return Err — the module exists in the graph but loading it produced an error (fetch failure, permission denial, syntax error, unstable loader state). For dynamic imports this is tolerated (the visitor returns Ok(None) and the import is simply not embedded), but for a statically reachable specifier the error is propagated as \"failed to load '<specifier>': <err>\".","triggerScenarios":"A static import of a URL that returned 404/500 while building the graph; a local file with unreadable permissions; a TypeScript/JSX file that failed parsing; a data:/npm: specifier the loader rejected. The underlying loader error text is appended after the colon.","commonSituations":"deno compile against a remote server that is down or rate-limiting; private registry auth token expired so npm/jsr fetches fail; file locked by antivirus on Windows; running compile with restricted --allow-net/--allow-read so the loader could not fetch/read dependencies.","solutions":["Read the suffix after the colon — it carries the root cause (HTTP status, ENOENT, parse error)","Run `deno cache <entry>` to reproduce the fetch/load failure with full diagnostics, fix it (auth token, network, file path), then retry compile","For private registries, re-export DENO_AUTH_TOKENS / .npmrc credentials in the build environment","Grant the permissions the build needs (network for remote deps, read for local files) or vendor the dependencies"],"exampleFix":"# before\ndeno compile src/mod.ts  # failed to load 'https://example.com/lib.js': Not Found\n\n# after\n# fix or pin the broken dependency, then\nimport { lib } from \"https://example.com/lib.js@0.4.2\";\ndeno cache src/mod.ts && deno compile src/mod.ts","handlingStrategy":"try-catch","validationCode":"# Preflight: surface loader errors with full diagnostics first\ndeno check --all src/mod.ts  # fetch + parse everything compile will load","typeGuard":null,"tryCatchPattern":"const { success, stderr } = await new Deno.Command(\"deno\", { args: [\"compile\", \"src/mod.ts\"] }).output();\nconst err = new TextDecoder().decode(stderr);\nconst m = err.match(/failed to load '(\\S+)': (.+)/);\nif (!success && m) {\n  const [, specifier, cause] = m;\n  if (/40[134]|Not Found/i.test(cause)) pinOrRemoveDependency(specifier);\n  else if (/enoent|permission/i.test(cause)) fixLocalPathOrPerms(specifier);\n}","preventionTips":["Run compile in an environment with network + read permissions for all deps","Re-export registry tokens (DENO_AUTH_TOKENS, .npmrc) in CI build jobs","Fail CI on any warning during deno cache so broken deps never reach compile"],"tags":["eszip","module-graph","compile","loading","network"],"backgroundTag":"module-load-failure","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}