angular/angular-cli · error · CommandError

Unable to fetch package information for '${context.packageId

Error message

Unable to fetch package information for '${context.packageIdentifier}': ${e.message}

What it means

Thrown by loadPackageInfoTask when `packageManager.getManifest(packageIdentifier)` rejects. The original error is asserted to be an Error and its message is appended, so this error surfaces network failures, 404s, or auth errors from the registry while fetching the manifest for the package given to `ng add`.

Source

Thrown at packages/angular/cli/src/commands/add/cli.ts:535

    return [...majorVersions.values()].sort((a, b) => compare(b, a, true));
  }

  private async loadPackageInfoTask(
    context: AddCommandTaskContext,
    task: AddCommandTaskWrapper,
    options: Options<AddCommandArgs>,
  ): Promise<void> {
    const { registry } = options;

    let manifest;
    try {
      manifest = await this.context.packageManager.getManifest(context.packageIdentifier, {
        registry,
      });
    } catch (e) {
      assertIsError(e);
      throw new CommandError(
        `Unable to fetch package information for '${context.packageIdentifier}': ${e.message}`,
      );
    }

    if (!manifest) {
      throw new CommandError(
        `Unable to fetch package information for '${context.packageIdentifier}'.`,
      );
    }

    // Avoid fully resolving the package version from the registry again in later steps
    if (context.packageIdentifier.registry) {
      assert(context.packageIdentifier.name, 'Registry package identifier must have a name');
      context.packageIdentifier = npa.resolve(
        context.packageIdentifier.name,
        // `save-prefix` option is ignored by some package managers so the caret is needed to ensure
        // that the value in the project package.json is correct.
        (context.isExactVersion ? '' : '^') + manifest.version,

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Read the appended `${e.message}` — it names the root cause (DNS, 404, 401, etc.) and fix accordingly.
  2. Confirm connectivity: `npm view <package>` against the same registry configured in .npmrc.
  3. For private packages, add the correct auth token to .npmrc (`//registry.example.com/:_authToken=...`).
  4. If offline, ensure the package tarball/cache is available locally or connect to the network/VPN and retry.

Example fix

// before
ng add @mycompany/internal-lib   # 401 from private registry
# after adding token to .npmrc
// after
npm login --registry=https://registry.mycompany.com
ng add @mycompany/internal-lib
Defensive patterns

Strategy: retry

Validate before calling

const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(pkg)}`);
if (!res.ok) throw new Error(`Registry returned ${res.status} for ${pkg}`);

Type guard

function isFetchError(e: unknown): e is Error & { code?: string } {
  return e instanceof Error && ('code' in e || typeof e.message === 'string');
}

Try / catch

try {
  await exec('ng', ['add', pkg, '--skip-confirmation']);
} catch (e) {
  if (e instanceof Error && /Unable to fetch package information/.test(e.message)) {
    await waitForNetwork();      // backoff then retry
    await exec('ng', ['add', pkg, '--skip-confirmation']);
  } else throw e;
}

Prevention

When it happens

Trigger: `this.context.packageManager.getManifest(context.packageIdentifier, { registry })` throws — registry unreachable (ENOTFOUND/ECONNREFUSED), HTTP 404 for unknown package, 401/403 for private packages, TLS/proxy failures.

Common situations: Offline development; VPN/corporate proxy blocking registry access; typo in package name; private scoped package without auth token in .npmrc; self-signed certificate or custom registry outage.

Related errors


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/edf5a491585863bd. Report an issue: GitHub.