yarnpkg/yarn · error · MessageError
couldntFindVersionThatMatchesRange
Error message
couldntFindVersionThatMatchesRange
What it means
After semver.maxSatisfying finds no match and an optional interactive version prompt yields no selection, Yarn throws — no published version in the registry satisfies the requested range.
Source
Thrown at src/resolvers/registries/npm-resolver.js:84
config.reporter.log(config.reporter.lang('couldntFindVersionThatMatchesRange', body.name, range));
let pageSize;
if (process.stdout instanceof tty.WriteStream) {
pageSize = process.stdout.rows - 2;
}
const response: {[key: string]: ?string} = await inquirer.prompt([
{
name: 'package',
type: 'list',
message: config.reporter.lang('chooseVersionFromList', body.name),
choices: (semver: Object).rsort(Object.keys(body.versions)),
pageSize,
},
]);
if (response && response.package) {
return body.versions[response.package];
}
}
throw new MessageError(config.reporter.lang('couldntFindVersionThatMatchesRange', body.name, range));
}
async resolveRequest(desiredVersion: ?string): Promise<?Manifest> {
if (this.config.offline) {
const res = await this.resolveRequestOffline();
if (res != null) {
return res;
}
}
const escapedName = NpmRegistry.escapeName(this.name);
const desiredRange = desiredVersion || this.range;
const body = await this.config.registries.npm.request(escapedName);
if (body) {
return NpmResolver.findVersionInRegistryResponse(this.config, escapedName, desiredRange, body, this.request);
} else {
return null;View on GitHub (pinned to c2dda503f3)
Solutions
- Loosen or correct the version range in package.json
- Check available versions with yarn info <package> versions
- Pin to a specific existing version that is published
- If the version should exist, verify the registry mirror is up to date
Example fix
// before "dep": "^3.0.0" // after (no v3 published yet) "dep": "^2.5.0"
Defensive patterns
Strategy: validation
Validate before calling
import * as semver from 'semver';
function rangeHasMatch(versions: string[], range: string): boolean {
return semver.maxSatisfying(versions, range) !== null;
}
if (!rangeHasMatch(Object.keys(body.versions), range)) {
console.warn(`No version of ${name} satisfies ${range}`);
} Type guard
function isSatisfiableRange(versions: string[], range: string): boolean {
return semver.maxSatisfying(versions, range) !== null;
} Try / catch
try {
const manifest = await NpmResolver.findVersionInRegistryResponse(config, name, range, body);
} catch (e) {
if (e.message.includes('couldntFindVersionThatMatchesRange')) {
// broaden the range or pin to an existing version
}
} Prevention
- Run yarn info <package> versions to confirm a version exists before pinning
- Avoid overly narrow or speculative ranges
- Keep registry mirrors up to date
When it happens
Trigger: A dependency range (e.g., ^2.0.0) that no published version satisfies, and the interactive fallback returns nothing or is unavailable. Terminal failure of findVersionInRegistryResponse.
Common situations: Requesting a range before the target version is published; typo in the semver range; package only has older major versions.
Related errors
- importResolveFailed
- Release not found: ${range}
- requiredVersionInRange
- invalidVersionArgument
- invalidVersion
AI-assisted analysis of yarnpkg/yarn@c2dda503f3 (2026-08-13).
Data as JSON: /api/errors/39ecee90fba2abee.
Report an issue: GitHub.