yarnpkg/yarn · error · MessageError
registryNoVersions
Error message
registryNoVersions
What it means
findVersionInRegistryResponse() throws when body.versions exists but is an empty object — the registry returned a packument with zero published versions. Yarn needs at least one version to resolve.
Source
Thrown at src/resolvers/registries/npm-resolver.js:40
type RegistryResponse = {
name: string,
versions: {[key: string]: Manifest},
'dist-tags': {[key: string]: string},
};
export default class NpmResolver extends RegistryResolver {
static registry = NPM_REGISTRY_ID;
static async findVersionInRegistryResponse(
config: Config,
name: string,
range: string,
body: RegistryResponse,
request: ?PackageRequest,
): Promise<Manifest> {
if (body.versions && Object.keys(body.versions).length === 0) {
throw new MessageError(config.reporter.lang('registryNoVersions', body.name));
}
if (!body['dist-tags'] || !body.versions) {
throw new MessageError(config.reporter.lang('malformedRegistryResponse', name));
}
if (range in body['dist-tags']) {
range = body['dist-tags'][range];
}
// If the latest tag in the registry satisfies the requested range, then use that.
// Otherwise we will fall back to semver maxSatisfying.
// This mimics logic in NPM. See issue #3560
const latestVersion = body['dist-tags'] ? body['dist-tags'].latest : undefined;
if (latestVersion && semver.satisfies(latestVersion, range)) {
return body.versions[latestVersion];
}
View on GitHub (pinned to c2dda503f3)
Solutions
- Verify the package still has published versions (npm view <name> versions)
- Pin to a different package or an older cached version
- Switch to a registry mirror that has the package cached
- If unpublished, remove it from package.json
Defensive patterns
Strategy: validation
Validate before calling
function hasPublishedVersions(body: {versions?: object}): boolean {
return !!body.versions && Object.keys(body.versions).length > 0;
} Type guard
function registryHasVersions(body: object): boolean {
return 'versions' in body && Object.keys((body as any).versions || {}).length > 0;
} Try / catch
try {
const manifest = await NpmResolver.findVersionInRegistryResponse(config, name, range, body);
} catch (e) {
if (e.message.includes('registryNoVersions')) {
// select an alternative package or cached version
}
} Prevention
- Check npm view <name> versions before pinning
- Avoid depending on packages at risk of unpublish
- Mirror critical packages to a private registry
When it happens
Trigger: A package whose registry metadata has a versions object with no keys. Checked at the top of findVersionInRegistryResponse before dist-tags lookup.
Common situations: Recently unpublished packages (all versions removed); registry replication lag leaving an empty doc; beta/internal registries with incomplete data.
Related errors
- importResolveFailed
- packageNotFoundRegistry
- Unexpected audit response (Invalid JSON): ${response}
- Unexpected audit response (Missing Metadata): ${JSON.stringi
- nonInteractiveNoToken
AI-assisted analysis of yarnpkg/yarn@c2dda503f3 (2026-08-13).
Data as JSON: /api/errors/43bcb4821249918a.
Report an issue: GitHub.