{"record":{"id":"5b8f096c907213d6","repo":"denoland/deno","slug":"deno-is-not-supported-when-configuration-file","errorCode":null,"errorMessage":"`deno {}` is not supported when configuration file contains an \"importMap\" field. Inline the import map into the Deno configuration file.\n    at {}","messagePattern":"`deno (.+?)` is not supported when configuration file contains an \"importMap\" field\\. Inline the import map into the Deno configuration file\\.\n    at (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/pm/mod.rs","lineNumber":553,"sourceCode":"\npub async fn add(\n  flags: Arc<Flags>,\n  add_flags: AddFlags,\n  cmd_name: AddCommandName,\n) -> Result<(), AnyError> {\n  let save_exact = add_flags.save_exact;\n  let (cli_factory, force_package_json, mut npm_config, mut deno_config) =\n    load_configs(\n      &flags,\n      || add_flags.packages.iter().any(|s| s.starts_with(\"jsr:\")),\n      add_flags.package_json,\n      true,\n    )?;\n\n  if let Some(deno) = &deno_config\n    && deno.obj().get(\"importMap\").is_some()\n  {\n    bail!(\n      concat!(\n        \"`deno {}` is not supported when configuration file contains an \\\"importMap\\\" field. \",\n        \"Inline the import map into the Deno configuration file.\\n\",\n        \"    at {}\",\n      ),\n      cmd_name,\n      deno.display_path(),\n    );\n  }\n\n  let start_dir = cli_factory.cli_options()?.start_dir.dir_path();\n\n  // only prefer to add npm deps to `package.json` if there isn't a closer deno.json.\n  // example: if deno.json is in the CWD and package.json is in the parent, we should add\n  // npm deps to deno.json, since it's closer\n  let prefer_npm_config = match (npm_config.as_ref(), deno_config.as_ref()) {\n    (Some(npm), Some(deno)) => {\n      let npm_distance = path_distance(&npm.path, &start_dir);","sourceCodeStart":535,"sourceCodeEnd":571,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/pm/mod.rs#L535-L571","documentation":"Dependency-mutating commands (`deno add`/`remove`, via cmd_name) refuse to run when the active deno.json still uses the legacy top-level `\"importMap\"` field. The config updater rewrites deno.json, and external import map files cannot be edited safely, so Deno asks you to inline the map first.","triggerScenarios":"deno.json contains `\"importMap\": \"./import.map.json\"` (top-level field) and you run `deno add ...` or `deno remove ...`. The check reads the `importMap` key on the loaded config object.","commonSituations":"Older projects predating inline `imports`; migration leftovers; import map maintained as a separate file shared across tools.","solutions":["Move the map contents into deno.json under `\"imports\"` and delete the `importMap` field, then re-run the command.","Keep `scopes` too if your map used them: `{ \"imports\": {...}, \"scopes\": {...} }`.","Remove the now-unused import.map.json file to avoid confusion."],"exampleFix":"// deno.json (before)\n{ \"importMap\": \"./import.map.json\" }\n// import.map.json\n{ \"imports\": { \"foo\": \"https://example.com/foo/mod.ts\" } }\n// deno.json (after)\n{\n  \"imports\": { \"foo\": \"https://example.com/foo/mod.ts\" }\n}","handlingStrategy":"validation","validationCode":"const cfg = JSON.parse(readFileSync(\"deno.json\", \"utf8\"));\nif (\"importMap\" in cfg) {\n  console.error(\"deno.json uses legacy top-level 'importMap'; inline it as 'imports' first\");\n  process.exit(1);\n}","typeGuard":"const usesLegacyImportMap = (cfg: Record<string, unknown>): boolean =>\n  \"importMap\" in cfg;","tryCatchPattern":null,"preventionTips":["Migrate `\"importMap\": \"./file.json\"` to an inline `\"imports\"` object once; the legacy field blocks config-updating commands.","Delete the external import map file after migrating to prevent regressions.","Add a CI check that fails if the top-level importMap key reappears."],"tags":["deno-json","import-map","config","migration"],"backgroundTag":"import-map-misconfigured","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}