denoland/deno · error · AnyError

No latest version for

Error message

No latest version for {registry_name}

What it means

Thrown by resolve_jsr_version() when a JSR/registry dependency is requested without an explicit version: the resolver reads `dist-tags.latest` from the fetched registry metadata and errors when the key is missing or not a string. Unlike npm, there is no fallback to sorting versions — no latest tag means no default version can be chosen.

Solutions

  1. Pin an explicit version: `deno add jsr:@scope/pkg@1.2.3`
  2. Inspect the metadata: `curl https://jsr.io/@scope/pkg/meta.json` and check the dist-tags object
  3. If you own the package, complete a real `deno publish` so the latest tag is written
  4. If a proxy/mirror serves the registry, fix it to pass dist-tags through, then retry with a clean cache (e.g. DENO_DIR=/tmp/deno deno add ...)

Example fix

# before
deno add jsr:@scope/pkg

# after
deno add jsr:@scope/pkg@0.1.0
Defensive patterns

Strategy: validation

Validate before calling

const meta = await fetch(`${REGISTRY}/${name}/meta.json`).then(r => r.json());
if (typeof meta?.['dist-tags']?.latest !== 'string') {
  throw new Error(`${name} has no latest tag; pin an exact version`);
}

Type guard

interface MetaWithLatest { 'dist-tags': { latest: string } }
const hasLatestTag = (m: unknown): m is MetaWithLatest =>
  !!m && typeof m === 'object' &&
  typeof (m as Record<string, any>)['dist-tags']?.latest === 'string';

Prevention

When it happens

Trigger: Running `deno add jsr:@scope/pkg` with no version when the metadata served by the registry named in the message has no `dist-tags.latest` key, or `latest` is null/not a JSON string, at cli/tools/installer/npm_compat.rs:1456.

Common situations: Package only ever published with `deno publish --dry-run`, or unpublished so tags were dropped; a private registry mirror or proxy that forwards `versions` but strips `dist-tags`; corrupted cached metadata; scope/package typo returning stub metadata.

Related errors


AI-assisted analysis of denoland/deno@336da420f4 (2026-08-20). Data as JSON: /api/errors/dfc6bb0359776329. Report an issue: GitHub.

Appendix: source

Thrown at cli/tools/installer/npm_compat.rs:1587

        }
      }
    }
  }
  out
}

fn resolve_jsr_version(
  metadata: &Value,
  req_version: Option<&str>,
  registry_name: &str,
) -> Result<String, AnyError> {
  match req_version {
    None => metadata
      .get("dist-tags")
      .and_then(|dt| dt.get("latest"))
      .and_then(|v| v.as_str())
      .map(|s| s.to_string())
      .ok_or_else(|| anyhow!("No latest version for {registry_name}")),
    Some(req_str) => {
      if let Ok(exact) = Version::parse_standard(req_str)
        && metadata
          .get("versions")
          .and_then(|vs| vs.get(exact.to_string()))
          .is_some()
      {
        return Ok(exact.to_string());
      }

      let version_req = VersionReq::parse_from_npm(req_str)
        .map_err(|e| anyhow!("Invalid version req '{req_str}': {e}"))?;

      let versions = metadata
        .get("versions")
        .and_then(|vs| vs.as_object())
        .ok_or_else(|| anyhow!("No versions for {registry_name}"))?;

View on GitHub (pinned to 336da420f4)