angular/angular-cli · error

UNKNOWN_ERROR

UNKNOWN_ERROR

Error message

UNKNOWN_ERROR

What it means

parseYarnClassicError is the fallback parser for Yarn 1 (classic) failures. It scans the JSON-lines output for a structured {type:'error', data:string} record and, when found, returns code 'UNKNOWN_ERROR' with that message as the summary — Yarn classic provides no error code taxonomy, so the CLI labels it generically.

Source

Thrown at packages/angular/cli/src/package-managers/parsers.ts:628

    // Status codes in the 200-299 range are successful.
    if (statusCode < 200 || statusCode >= 300) {
      logger?.debug(`  Detected HTTP error status code '${statusCode}' in verbose output.`);

      return {
        code: `E${statusCode}`,
        summary: `Request failed with status code ${statusCode}.`,
      };
    }
  }

  // Fallback to the JSON error type if no HTTP status code is present.
  for (const json of parseJsonLines(output, logger)) {
    if (json.type === 'error' && typeof json.data === 'string') {
      const summary = json.data;
      logger?.debug(`  Successfully parsed generic yarn classic error.`);

      return {
        code: 'UNKNOWN_ERROR',
        summary,
      };
    }
  }

  logger?.debug('  Failed to parse yarn classic error. No structured error found.');

  return null;
}

/**
 * Parses the output of `bun pm ls`.
 *
 * Bun does not support JSON output for `pm ls`. The output is a tree structure:
 * ```
 * /path/to/project node_modules (1084)
 * ├── @angular/core@20.3.15
 * ├── rxjs @7.8.2

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Read the 'summary' field in the error details — it contains Yarn's actual reason — and fix that underlying issue.
  2. Retry after confirming registry reachability (npm ping / curl the registry URL); many cases are transient network failures.
  3. Delete yarn.lock and node_modules and reinstall if resolution state is corrupted (`rm -rf node_modules yarn.lock && yarn install`).
  4. Clear the Yarn cache (`yarn cache clean`) for corrupted-package errors, or pin a resolvable version of the failing dependency.
Defensive patterns

Strategy: retry

Validate before calling

// Pre-check registry reachability before install
const res = await fetch('https://registry.yarnpkg.com/<pkg>');
if (!res.ok) throw new Error(`Registry unreachable (HTTP ${res.status}); aborting install`);

Type guard

function isPackageMgrError(e: unknown): e is { code: string; summary: string } {
  return typeof e === 'object' && e !== null && 'code' in e && 'summary' in e &&
    typeof (e as { summary: unknown }).summary === 'string';
}

Try / catch

try {
  await addPackage(name);
} catch (e) {
  if (isPackageMgrError(e) && e.code === 'UNKNOWN_ERROR') {
    console.error(`Yarn classic failed: ${e.summary} — fix the underlying cause or retry on transient network errors.`);
  } else throw e;
}

Prevention

When it happens

Trigger: A `yarn add`/install command run through the Angular CLI package manager fails and its output contains a typed error JSON line; the parser converts it to UNKNOWN_ERROR with the raw Yarn summary. Any Yarn 1 network, resolver, or integrity failure surfaces this way.

Common situations: Registry outages or 404s for a package version, peer dependency resolution conflicts, network/proxy failures, corrupted yarn.lock, or Yarn cache issues.

Related errors


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