angular/angular-cli · error · CommandError

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

Error message

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

What it means

Companion error to [16]: thrown by loadPackageInfoTask when getManifest resolves successfully but returns a falsy manifest. The CLI cannot continue resolving the package version or entry point, so it throws this message-less CommandError.

Source

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

    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,
      );
    }

    context.hasSchematics = !!manifest.schematics;
    context.savePackage = manifest['ng-add']?.save;
    context.collectionName = manifest.name;

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Double-check the exact package name/spec passed to `ng add` (spelling, scope, version tag).
  2. Run `npm view <name>@<spec>` to confirm the registry returns a manifest for that exact specifier.
  3. Use an explicit version/tag (e.g. `ng add @angular/cli@latest`) instead of an ambiguous specifier.
  4. If using a mirror/private registry, verify it proxies the package correctly.

Example fix

// before
ng add material
// after
ng add @angular/material
Defensive patterns

Strategy: validation

Validate before calling

const manifest = child.execSync(`npm view ${spec} name version`, { encoding: 'utf8' });
if (!manifest.trim()) throw new Error(`No manifest found for ${spec}`);

Type guard

function isValidPackageSpec(spec: string): boolean {
  return /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*(@[a-z0-9-._~]+)?$/.test(spec);
}

Try / catch

try {
  await runNgAdd(spec);
} catch (e) {
  if (e instanceof Error && e.message.includes("Unable to fetch package information for '")) {
    console.error(`Check package spec '${spec}': not found on registry.`);
  }
  throw e;
}

Prevention

When it happens

Trigger: `packageManager.getManifest(...)` resolves to null/undefined — typically when the underlying package manager implementation cannot find the manifest for the identifier (nonexistent package, malformed name/spec that resolves to nothing) without raising an exception.

Common situations: Misspelled or empty package identifier; passing a local path or tag that the package manager silently fails to resolve; registry returning an empty payload for an unpublished package.

Related errors


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