{"record":{"id":"43bcb4821249918a","repo":"yarnpkg/yarn","slug":"registrynoversions","errorCode":null,"errorMessage":"registryNoVersions","messagePattern":"registryNoVersions","errorType":"exception","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/resolvers/registries/npm-resolver.js","lineNumber":40,"sourceCode":"\ntype RegistryResponse = {\n  name: string,\n  versions: {[key: string]: Manifest},\n  'dist-tags': {[key: string]: string},\n};\n\nexport default class NpmResolver extends RegistryResolver {\n  static registry = NPM_REGISTRY_ID;\n\n  static async findVersionInRegistryResponse(\n    config: Config,\n    name: string,\n    range: string,\n    body: RegistryResponse,\n    request: ?PackageRequest,\n  ): Promise<Manifest> {\n    if (body.versions && Object.keys(body.versions).length === 0) {\n      throw new MessageError(config.reporter.lang('registryNoVersions', body.name));\n    }\n\n    if (!body['dist-tags'] || !body.versions) {\n      throw new MessageError(config.reporter.lang('malformedRegistryResponse', name));\n    }\n\n    if (range in body['dist-tags']) {\n      range = body['dist-tags'][range];\n    }\n\n    // If the latest tag in the registry satisfies the requested range, then use that.\n    // Otherwise we will fall back to semver maxSatisfying.\n    // This mimics logic in NPM. See issue #3560\n    const latestVersion = body['dist-tags'] ? body['dist-tags'].latest : undefined;\n    if (latestVersion && semver.satisfies(latestVersion, range)) {\n      return body.versions[latestVersion];\n    }\n","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/resolvers/registries/npm-resolver.js#L22-L58","documentation":"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.","triggerScenarios":"A package whose registry metadata has a versions object with no keys. Checked at the top of findVersionInRegistryResponse before dist-tags lookup.","commonSituations":"Recently unpublished packages (all versions removed); registry replication lag leaving an empty doc; beta/internal registries with incomplete data.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function hasPublishedVersions(body: {versions?: object}): boolean {\n  return !!body.versions && Object.keys(body.versions).length > 0;\n}","typeGuard":"function registryHasVersions(body: object): boolean {\n  return 'versions' in body && Object.keys((body as any).versions || {}).length > 0;\n}","tryCatchPattern":"try {\n  const manifest = await NpmResolver.findVersionInRegistryResponse(config, name, range, body);\n} catch (e) {\n  if (e.message.includes('registryNoVersions')) {\n    // select an alternative package or cached version\n  }\n}","preventionTips":["Check npm view <name> versions before pinning","Avoid depending on packages at risk of unpublish","Mirror critical packages to a private registry"],"tags":["registry","versions","resolution"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}