{"record":{"id":"78e6ebb4a929eb3d","repo":"denoland/deno","slug":"module-not-found","errorCode":null,"errorMessage":"module not found {}","messagePattern":"module not found (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"libs/eszip/v2.rs","lineNumber":1367,"sourceCode":"    fn visit_module<'a>(\n      graph: &'a ModuleGraph,\n      module_kind_provider: &dyn ModuleKindResolver,\n      parser: CapturingEsParser,\n      transpile_options: &TranspileOptions,\n      emit_options: &EmitOptions,\n      modules: &mut LinkedHashMap<String, EszipV2Module>,\n      visited: ToVisit,\n      relative_file_base: Option<EszipRelativeFileBaseUrl>,\n      npm_packages: Option<&mut FromGraphNpmPackages>,\n      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 =","sourceCodeStart":1349,"sourceCodeEnd":1385,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/libs/eszip/v2.rs#L1349-L1385","documentation":"When Deno serializes a module graph into an eszip archive (deno compile / deno bundle internals), every visited specifier must be found in the graph via graph.try_get(). Ok(None) means the specifier was queued for visiting but no module exists for it in the graph that was passed in — the graph and the visit queue disagree, so the build fails with 'module not found <specifier>'.","triggerScenarios":"Building an eszip from a graph that was constructed with a different entry point or with errors skipped; a dependency edge (e.g. from a resolved import in a cached package.json or import map) pointing at a specifier never loaded into the graph; file deleted or remote module evicted from cache between graph construction and serialization.","commonSituations":"deno compile failing after a DENO_DIR cache purge or when --no-remote-style restrictions excluded a module; mismatched graphs after editing entry points while reusing a stale in-process graph; tooling built on the eszip crate passing a graph and visitor set built from separate runs.","solutions":["Re-run `deno cache <entry>` (or delete DENO_DIR and retry) so every specifier is freshly loaded before compiling","Run `deno check <entry>` first — unresolved imports surface there with better diagnostics","Ensure the graph passed to eszip was built from the same entry point and loader that produced the visit queue (don't mix graphs across runs)","If a third-party dependency fails to resolve, pin a working version in the import map or package.json"],"exampleFix":"# before\ndeno compile src/mod.ts  # module not found https://example.com/lib.js\n\n# after\ndeno cache src/mod.ts && deno compile src/mod.ts","handlingStrategy":"try-catch","validationCode":"# Make every specifier resolvable BEFORE compiling\n# (a successful cache guarantees graph.try_get() finds each module)\ndeno check --all src/mod.ts && deno cache src/mod.ts","typeGuard":null,"tryCatchPattern":"// Tooling around `deno compile`\nconst p = new Deno.Command(\"deno\", { args: [\"compile\", \"-o\", \"app\", \"src/mod.ts\"] });\nconst { success, stderr } = await p.output();\nconst err = new TextDecoder().decode(stderr);\nif (!success && err.includes(\"module not found\")) {\n  const spec = err.match(/module not found (\\S+)/)?.[1];\n  // re-cache just that specifier: deno cache <spec>, then retry\n}","preventionTips":["Run deno cache/check in CI before compile steps","Don't build graphs and eszips from different sessions or entry points","Keep remote imports version-pinned so caches stay reproducible"],"tags":["eszip","module-graph","compile","bundling","module-resolution"],"backgroundTag":"module-not-found","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"}