{"record":{"id":"b6c99f46703ada46","repo":"angular/angular-cli","slug":"unable-to-load-package-information-from-registry-b6c99f","errorCode":null,"errorMessage":"Unable to load package information from registry.","messagePattern":"Unable to load package information from registry\\.","errorType":"exception","errorClass":"CommandError","httpStatus":null,"severity":"error","filePath":"packages/angular/cli/src/commands/add/cli.ts","lineNumber":397,"sourceCode":"      throw new CommandError(`Unable to load package information from registry: ${e.message}`);\n    }\n\n    // 'latest' is invalid or not found, search for most recent matching package.\n    task.output =\n      'Could not find a compatible version with `latest`. Searching for a compatible version.';\n\n    let packageMetadata;\n    try {\n      packageMetadata = await packageManager.getRegistryMetadata(packageName, {\n        registry,\n      });\n    } catch (e) {\n      assertIsError(e);\n      throw new CommandError(`Unable to load package information from registry: ${e.message}`);\n    }\n\n    if (!packageMetadata) {\n      throw new CommandError('Unable to load package information from registry.');\n    }\n\n    // Allow prelease versions if the CLI itself is a prerelease or locally built.\n    const allowPrereleases = !!prerelease(VERSION.full) || VERSION.full === '0.0.0';\n    const potentialVersions = this.#getPotentialVersions(packageMetadata, allowPrereleases);\n\n    // Heuristic-based search: Check the latest release of each major version first.\n    const majorVersions = this.#getMajorVersions(potentialVersions);\n    let found = await this.#findCompatibleVersion(context, majorVersions, {\n      registry,\n      verbose,\n      rejectionReasons,\n    });\n\n    // Exhaustive search: If no compatible major version is found, fall back to checking all versions.\n    if (!found) {\n      const checkedVersions = new Set(majorVersions);\n      const remainingVersions = potentialVersions.filter((v) => !checkedVersions.has(v));","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/commands/add/cli.ts#L379-L415","documentation":"This CommandError is thrown by findCompatiblePackageVersionTask in the `ng add` command when the package metadata could not be loaded from the npm registry. The code first tries to load metadata inside a try/catch (rethrowing with the underlying message); if the call returns no metadata at all (null/undefined) without throwing, this message-less variant is thrown. It means the CLI has no version information to pick a compatible version from.","triggerScenarios":"The registry request completes but returns falsy packageMetadata — e.g. the package does not exist, the registry returns an empty/unexpected response, or packageManager.getMetadata resolves with null for a nonexistent or misspelled package name.","commonSituations":"Typo in the package name passed to `ng add`; private registry/proxy that returns 200 with an empty body; offline or misconfigured .npmrc registry; package unpublished or renamed.","solutions":["Verify the package name and that it exists on the configured registry (`npm view <package> version`).","Check .npmrc registry configuration and network/proxy connectivity; run with --verbose for details.","Retry when the registry is reachable; if behind a corporate proxy, configure proxy settings for npm.","As a last resort, install the package manually with your package manager and run `ng add <package>--skip-confirmation`-style flows or `ng generate` schematics directly."],"exampleFix":"// before\nng add @angular/materiall\n// after\nng add @angular/material","handlingStrategy":"validation","validationCode":"const version = child.execSync(`npm view ${pkg} version`, { encoding: 'utf8' }).trim();\nif (!version) throw new Error(`Package ${pkg} not resolvable from registry`);","typeGuard":"function hasPackageMetadata(m: unknown): m is { versions: Record<string, unknown>; 'dist-tags': Record<string, string> } {\n  return !!m && typeof m === 'object' && 'versions' in m && 'dist-tags' in m;\n}","tryCatchPattern":"try {\n  await runNgAdd(pkg);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Unable to load package information')) {\n    // verify name/registry, then retry or fail the script with a clear message\n  }\n  throw e;\n}","preventionTips":["Always smoke-test `npm view <package> version` before scripted `ng add` usage.","Pin the registry in .npmrc and audit it in CI.","Spell-check scoped package names; prefer copy-paste from package docs.","Run `ng add` with --verbose first when introducing a new registry or proxy."],"tags":["network","registry","npm","angular-cli"],"backgroundTag":"registry-metadata-unavailable","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}