{"record":{"id":"eb296676af141b9d","repo":"denoland/deno","slug":"unhandled-scenario-where-a-duplicate-entry-was-fou","errorCode":null,"errorMessage":"Unhandled scenario where a duplicate entry was found: {:?}","messagePattern":"Unhandled scenario where a duplicate entry was found: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/standalone/binary.rs","lineNumber":1533,"sourceCode":"          npm_resolver.known_registries_dirnames().to_vec();\n        let mut localhost_entries: IndexMap<String, VfsEntry> = IndexMap::new();\n        let mut registry_top_segments: HashSet<String> = HashSet::new();\n        for registry_dirname in &known_registries_dirnames {\n          if let Some(first) = registry_dirname.split('/').next()\n            && !first.is_empty()\n          {\n            registry_top_segments.insert(first.to_string());\n          }\n          let registry_path = global_cache_root_path.join(registry_dirname);\n          let Some(registry_dir) = vfs.get_dir_mut(&registry_path) else {\n            continue;\n          };\n          for entry in registry_dir.entries.take_inner() {\n            log::debug!(\"Flattening {} into node_modules\", entry.name());\n            if let Some(existing) =\n              localhost_entries.insert(entry.name().to_string(), entry)\n            {\n              panic!(\n                \"Unhandled scenario where a duplicate entry was found: {:?}\",\n                existing\n              );\n            }\n          }\n        }\n\n        let Some(root_dir) = vfs.get_dir_mut(global_cache_root_path) else {\n          return vfs.build();\n        };\n\n        root_dir.name = DENO_COMPILE_GLOBAL_NODE_MODULES_DIR_NAME.to_string();\n        let mut new_entries = Vec::with_capacity(root_dir.entries.len());\n        for entry in root_dir.entries.take_inner() {\n          match &entry {\n            VfsEntry::Dir(dir) if registry_top_segments.contains(&dir.name) => {\n              // The packages under this registry host dir have already been\n              // flattened into `localhost_entries`. Drop the (now empty)","sourceCodeStart":1515,"sourceCodeEnd":1551,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/standalone/binary.rs#L1515-L1551","documentation":"Panic while building a `deno compile` binary (cli/standalone/binary.rs). For compiled binaries Deno constructs a virtual filesystem from the local node_modules cache and flattens the per-registry directories (e.g. a localhost registry cache) into node_modules, keyed by entry name. Two entries resolving to the same package name collide, which the VFS builder does not know how to merge, so it panics with the duplicate entry.","triggerScenarios":"Running `deno compile` on a project whose dependencies were resolved from multiple registry sources that both contributed a package with the same name into the global cache being flattened — e.g. an npm registry plus a localhost/mirrored registry ( Verdaccio proxy) yielding duplicate top-level entries.","commonSituations":"Compiling a project after switching registry configuration (custom .npmrc/registry mirrors, `nodeModulesDir` caches from different registries) so the same package exists twice under different registry roots in the DENO_DIR cache.","solutions":["Clear the package cache and re-resolve from a single registry: `deno clean` (or remove DENO_DIR's npm cache) then `deno install` and retry `deno compile`","Align registry configuration (.npmrc / NPM_CONFIG_REGISTRY / lockfile) so all packages resolve from one source before compiling","If it persists with one consistent registry, report it to the deno repo with the import map, deno.json, and the duplicate entry name from the panic message"],"exampleFix":"# before\n# cache holds same package from registry + localhost mirror\ndeno compile main.ts            # panics: duplicate entry\n# after\ndeno clean\ndeno install\ndeno compile main.ts","handlingStrategy":"fallback","validationCode":"# before compiling, assert one registry produced the cache\ndeno info --json 2>/dev/null | grep -i registry || true\n# simplest guard: start from a clean, single-registry cache\ndeno clean && deno install --frozen && deno compile main.ts","typeGuard":null,"tryCatchPattern":"# build script fallback: retry once after cleaning the cache\ndeno compile --output app main.ts || {\n  echo 'compile failed; retrying after deno clean' >&2\n  deno clean && deno install --frozen\n  deno compile --output app main.ts\n}","preventionTips":["Keep one registry configuration (.npmrc, lockfile) per project and commit the lockfile","Avoid mixing mirror/localhost registries with the public npm registry in the same cache lifecycle","Run `deno clean` when switching registry providers before producing compile artifacts"],"tags":["deno-compile","node-modules","vfs","duplicate-entry","npm-cache","registry"],"backgroundTag":"duplicate-package-entry","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}