denoland/deno · error
{entry_text} is missing a prefix. Did you mean `{}`?
Error message
{entry_text} is missing a prefix. Did you mean `{}`? What it means
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.
Source
Thrown at cli/tools/pm/mod.rs:658
add_req.package_name()
)),
);
}
}
package_reqs.push(add_req)
}
// Currently unreachable: default_registry is always Some (defaults to Npm),
// so parse() always resolves a prefix. Kept as a safety fallback in case
// the API is called with None from elsewhere.
Err(package_req) => {
if jsr_resolver
.req_to_nv(&package_req)
.await
.ok()
.flatten()
.is_some()
{
bail!(
"{entry_text} is missing a prefix. Did you mean `{}`?",
crate::colors::yellow(format!("deno {cmd_name} jsr:{package_req}"))
)
} else if npm_resolver
.req_to_nv(&package_req)
.await
.ok()
.flatten()
.is_some()
{
bail!(
"{entry_text} is missing a prefix. Did you mean `{}`?",
crate::colors::yellow(format!("deno {cmd_name} npm:{package_req}"))
)
} else {
bail!(
"{} was not found in either jsr or npm.",
crate::colors::red(entry_text)View on GitHub (pinned to 9ad36f7a2c)
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.
Example fix
# before deno add oak # after deno add jsr:oak
Defensive patterns
Strategy: validation
Validate before calling
const spec = process.argv[2] ?? "";
if (!spec.includes(":")) {
console.error(`bare specifier "${spec}"; be explicit: jsr:${spec} or npm:${spec}`);
process.exit(1);
} Type guard
const hasRegistryPrefix = (spec: string): boolean => /^(npm|jsr|http|https|file|data|node):/.test(spec);
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Only npm packages are supported: {}
- Unexpected package json dependency string: "{string_value}"
- unable to find npm package in workspace
- missing version in package.json of npm package
- Either `node` or `range` must be provided when reporting an
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/011776c5f58b96c5.
Report an issue: GitHub.