{"record":{"id":"011776c5f58b96c5","repo":"denoland/deno","slug":"entry-text-is-missing-a-prefix-did-you-mean","errorCode":null,"errorMessage":"{entry_text} is missing a prefix. Did you mean `{}`?","messagePattern":"(.+?) is missing a prefix\\. Did you mean `(.+?)`\\?","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/pm/mod.rs","lineNumber":658,"sourceCode":"                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\n          .req_to_nv(&package_req)\n          .await\n          .ok()\n          .flatten()\n          .is_some()\n        {\n          bail!(\n            \"{entry_text} is missing a prefix. Did you mean `{}`?\",\n            crate::colors::yellow(format!(\"deno {cmd_name} jsr:{package_req}\"))\n          )\n        } else if npm_resolver\n          .req_to_nv(&package_req)\n          .await\n          .ok()\n          .flatten()\n          .is_some()\n        {\n          bail!(\n            \"{entry_text} is missing a prefix. Did you mean `{}`?\",\n            crate::colors::yellow(format!(\"deno {cmd_name} npm:{package_req}\"))\n          )\n        } else {\n          bail!(\n            \"{} was not found in either jsr or npm.\",\n            crate::colors::red(entry_text)","sourceCodeStart":640,"sourceCodeEnd":676,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/pm/mod.rs#L640-L676","documentation":"When `AddRmPackageReq::parse` cannot resolve a registry prefix for a bare specifier, the code checks whether the name exists on JSR or npm and, if so, tells you the exact prefixed command to run. Per the in-code comment this branch is currently unreachable through the CLI (default_registry always defaults to Npm) and acts as a safety net for API callers passing no default registry.","triggerScenarios":"Calling the add flow programmatically with no default registry and a bare name like `deno add oak` where `oak` resolves on JSR (suggests `jsr:oak`) or npm (suggests `npm:oak`). Bare names in the shipped CLI are auto-treated as npm and do not hit this.","commonSituations":"Embedders/tests invoking the internal add API with default_registry: None; older Deno versions where bare jsr packages were ambiguous; spec strings missing their `jsr:`/`npm:` prefix after tooling mangles input.","solutions":["Prefix the specifier explicitly: `deno add jsr:oak` or `deno add npm:chalk`, matching the suggestion in the message.","If scripting around the CLI, don't strip registry prefixes from user input.","On the CLI today, bare names resolve to npm by default — pass a default registry if you call the API directly."],"exampleFix":"# before\ndeno add oak\n# after\ndeno add jsr:oak","handlingStrategy":"validation","validationCode":"const spec = process.argv[2] ?? \"\";\nif (!spec.includes(\":\")) {\n  console.error(`bare specifier \"${spec}\"; be explicit: jsr:${spec} or npm:${spec}`);\n  process.exit(1);\n}","typeGuard":"const hasRegistryPrefix = (spec: string): boolean =>\n  /^(npm|jsr|http|https|file|data|node):/.test(spec);","tryCatchPattern":null,"preventionTips":["Always write the registry prefix (jsr:, npm:) in scripts and lockfiles.","If calling Deno's add API directly, pass a default registry so bare names resolve.","Never strip prefixes when forwarding user input to deno add."],"tags":["add","registry-prefix","jsr","npm"],"backgroundTag":"missing-registry-prefix","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"}