angular/angular-cli · error · CommandError
Unable to load package information from registry.
Error message
Unable to load package information from registry.
What it means
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.
Source
Thrown at packages/angular/cli/src/commands/add/cli.ts:397
throw new CommandError(`Unable to load package information from registry: ${e.message}`);
}
// 'latest' is invalid or not found, search for most recent matching package.
task.output =
'Could not find a compatible version with `latest`. Searching for a compatible version.';
let packageMetadata;
try {
packageMetadata = await packageManager.getRegistryMetadata(packageName, {
registry,
});
} catch (e) {
assertIsError(e);
throw new CommandError(`Unable to load package information from registry: ${e.message}`);
}
if (!packageMetadata) {
throw new CommandError('Unable to load package information from registry.');
}
// Allow prelease versions if the CLI itself is a prerelease or locally built.
const allowPrereleases = !!prerelease(VERSION.full) || VERSION.full === '0.0.0';
const potentialVersions = this.#getPotentialVersions(packageMetadata, allowPrereleases);
// Heuristic-based search: Check the latest release of each major version first.
const majorVersions = this.#getMajorVersions(potentialVersions);
let found = await this.#findCompatibleVersion(context, majorVersions, {
registry,
verbose,
rejectionReasons,
});
// Exhaustive search: If no compatible major version is found, fall back to checking all versions.
if (!found) {
const checkedVersions = new Set(majorVersions);
const remainingVersions = potentialVersions.filter((v) => !checkedVersions.has(v));View on GitHub (pinned to bb72145f9a)
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.
Example fix
// before ng add @angular/materiall // after ng add @angular/material
Defensive patterns
Strategy: validation
Validate before calling
const version = child.execSync(`npm view ${pkg} version`, { encoding: 'utf8' }).trim();
if (!version) throw new Error(`Package ${pkg} not resolvable from registry`); Type guard
function hasPackageMetadata(m: unknown): m is { versions: Record<string, unknown>; 'dist-tags': Record<string, string> } {
return !!m && typeof m === 'object' && 'versions' in m && 'dist-tags' in m;
} Try / catch
try {
await runNgAdd(pkg);
} catch (e) {
if (e instanceof Error && e.message.includes('Unable to load package information')) {
// verify name/registry, then retry or fail the script with a clear message
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unable to fetch package information for '${context.packageId
- ${parsedError.summary}
- Package ${name} was not found on the registry. Skipping.
- Could not find @angular/cli version '${runnerVersion}'.
- Unable to load package information from registry: ${e.messag
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/b6c99f46703ada46.
Report an issue: GitHub.