{"record":{"id":"69d77f62538c2f0a","repo":"denoland/deno","slug":"and-would-both-be-added-as-provide-an","errorCode":null,"errorMessage":"{} and {} would both be added as \"{}\". Provide an explicit alias for one of them (ex. `{}`).","messagePattern":"(.+?) and (.+?) would both be added as \"(.+?)\"\\. Provide an explicit alias for one of them \\(ex\\. `(.+?)`\\)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/pm/mod.rs","lineNumber":633,"sourceCode":"      bail!(\"{hint}\");\n    }\n    let req = AddRmPackageReq::parse(\n      entry_text,\n      add_flags.default_registry.map(|r| r.into()),\n    )\n    .with_context(|| format!(\"Failed to parse package: {}\", entry_text))?;\n\n    match req {\n      Ok(mut add_req) => {\n        if add_flags.unscoped {\n          add_req.use_unscoped_alias();\n          // packages from different scopes can share an unscoped name\n          // (ex. `@luca/flag` and `@other/flag`), which would otherwise\n          // silently overwrite each other in the config\n          if let Some(existing) =\n            package_reqs.iter().find(|r| r.alias == add_req.alias)\n          {\n            bail!(\n              \"{} and {} would both be added as \\\"{}\\\". Provide an explicit alias for one of them (ex. `{}`).\",\n              existing.package_name(),\n              add_req.package_name(),\n              add_req.alias,\n              crate::colors::yellow(format!(\n                \"deno {cmd_name} my-alias@{}\",\n                add_req.package_name()\n              )),\n            );\n          }\n        }\n        package_reqs.push(add_req)\n      }\n      // Currently unreachable: default_registry is always Some (defaults to Npm),\n      // so parse() always resolves a prefix. Kept as a safety fallback in case\n      // the API is called with None from elsewhere.\n      Err(package_req) => {\n        if jsr_resolver","sourceCodeStart":615,"sourceCodeEnd":651,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/pm/mod.rs#L615-L651","documentation":"With `--unscoped`, `deno add` strips scopes from names so `@a/cli` and `@b/cli` both become the import alias `cli`. Before inserting, it checks for an existing req with the same alias and bails, showing both package names and a concrete aliased command, because otherwise the second add would silently overwrite the first in deno.json.","triggerScenarios":"`deno add --unscoped @a/cli @b/cli` (two packages whose names after the scope are identical), or a second `--unscoped` add colliding with an existing dependency in the same invocation's list.","commonSituations":"Installing multiple scoped CLIs or libs with the same base name (e.g. @std/cli and @foo/cli); scripts that loop `deno add --unscoped` over package lists.","solutions":["Alias one of them explicitly: `deno add my-cli@npm:@b/cli` (pattern shown in the error message).","Drop `--unscoped` so each keeps its scoped key `@a/cli`.","Split into two invocations if both are needed unscoped, aliasing at least one."],"exampleFix":"# before\ndeno add --unscoped @a/cli @b/cli\n# after\ndeno add --unscoped @a/cli my-cli@npm:@b/cli","handlingStrategy":"validation","validationCode":"const specs = process.argv.slice(2); // after --unscoped\nconst unscoped = (s: string) => s.replace(/^@[^/]+\\//, \"\").split(\"@\")[0];\nconst seen = new Map<string, string>();\nfor (const s of specs) {\n  const alias = unscoped(s);\n  if (seen.has(alias)) {\n    console.error(`${seen.get(alias)} and ${s} collide on unscoped alias \"${alias}\"; alias one explicitly`);\n    process.exit(1);\n  }\n  seen.set(alias, s);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["With --unscoped, alias same-basename packages: `deno add my-cli@npm:@b/cli`.","Avoid --unscoped when installing several packages sharing a base name.","Review the generated deno.json imports after every add."],"tags":["add","alias","unscoped","dependencies"],"backgroundTag":"dependency-alias-conflict","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}