denoland/deno · error · AnyError

No version matching ' ' for

Error message

No version matching '{req_str}' for {registry_name}

What it means

Thrown by resolve_jsr_version() when the versions map exists but no listed key both parses as a standard version and satisfies the requested VersionReq — the loop keeps the highest match in `best` and errors when `best` stays None. This is Deno's equivalent of npm's ETARGET: a valid range with no satisfying published version.

Solutions

  1. List the published versions (registry page or meta.json `versions` keys) and pin one that exists
  2. Adjust the range to what is published, e.g. `^2.0.0` → `^1.9.0`
  3. For prerelease-only packages use the exact prerelease (`1.0.0-beta.3`) or an opt-in range like `>=1.0.0-0 <2`
  4. If a newer version should exist, refresh metadata (clear cache / --reload) and verify the package name and scope

Example fix

# before
deno add jsr:@scope/pkg@^2.0.0

# after (only 1.x published)
deno add jsr:@scope/pkg@^1.9.0
Defensive patterns

Strategy: validation

Validate before calling

import semver from 'npm:semver';
const versions = Object.keys(meta.versions);
const match = semver.maxSatisfying(versions, reqRange);
if (!match) throw new Error(`No version satisfies ${reqRange}`);

Type guard

const satisfiesAny = (versions: string[], range: string): boolean =>
  semver.maxSatisfying(versions, range) !== null;

Prevention

When it happens

Trigger: `deno add pkg@^2.0.0` when only 1.x versions are listed; ranges that exclude everything (`>=3.0.0`); prerelease-only packages, since npm semver semantics exclude prereleases from plain ranges unless the range opts into the same major.minor.patch tuple.

Common situations: Bumping a range to a major that was never published; depending on packages that ship only beta/rc versions; private registries with stale metadata missing newer releases; typo'd minor digit in the range.

Related errors


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

Appendix: source

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

        .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}"))?;

      let mut best: Option<Version> = None;
      for key in versions.keys() {
        if let Ok(v) = Version::parse_standard(key)
          && version_req.matches(&v)
          && best.as_ref().is_none_or(|b| v > *b)
        {
          best = Some(v);
        }
      }

      best.map(|v| v.to_string()).ok_or_else(|| {
        anyhow!("No version matching '{req_str}' for {registry_name}")
      })
    }
  }
}

#[cfg(test)]
mod tests {
  use super::*;

  #[test]
  fn test_scheme_package_name() {
    assert_eq!(
      scheme_package_name("jsr:@fresh/core@^2.0.0").as_deref(),
      Some("@fresh/core")
    );
    assert_eq!(scheme_package_name("npm:chalk@5").as_deref(), Some("chalk"));
    assert_eq!(
      scheme_package_name("npm:@scope/pkg@1.2.3").as_deref(),

View on GitHub (pinned to 336da420f4)