angular/angular-cli · error · Error

Invalid format version detected - Expected:[ 1 ] Found: [ ${

Error message

Invalid format version detected - Expected:[ 1 ] Found: [ ${version} ]

What it means

The only supported workspace format version is 1. After locating the 'version' node, the reader compares its value to 1 and throws this templated Error showing the expected and found values for any other number/type. This catches files written for newer or unknown format revisions.

Source

Thrown at packages/angular_devkit/core/src/workspace/json/reader.ts:63

): Promise<WorkspaceDefinition> {
  const raw = await host.readFile(path);
  if (raw === undefined) {
    throw new Error('Unable to read workspace file.');
  }

  const ast = parseTree(raw, undefined, { allowTrailingComma: true, disallowComments: false });
  if (ast?.type !== 'object' || !ast.children) {
    throw new Error('Invalid workspace file - expected JSON object.');
  }

  // Version check
  const versionNode = findNodeAtLocation(ast, ['version']);
  if (!versionNode) {
    throw new Error('Unknown format - version specifier not found.');
  }
  const version = versionNode.value;
  if (version !== 1) {
    throw new Error(`Invalid format version detected - Expected:[ 1 ] Found: [ ${version} ]`);
  }

  const context: ParserContext = {
    host,
    metadata: new JsonWorkspaceMetadata(path, ast, raw),
    trackChanges: true,
    unprefixedWorkspaceExtensions: new Set([
      ...ANGULAR_WORKSPACE_EXTENSIONS,
      ...(options.allowedWorkspaceExtensions ?? []),
    ]),
    unprefixedProjectExtensions: new Set([
      ...ANGULAR_PROJECT_EXTENSIONS,
      ...(options.allowedProjectExtensions ?? []),
    ]),
    error(message, _node) {
      // TODO: Diagnostic reporting support
      throw new Error(message);
    },

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Set "version": 1 (numeric, unquoted) at the top level of the workspace file.
  2. If the file came from a newer tool version, use a matching/newer version of the tooling that supports that format.
  3. Restore the file from version control if the version was modified by mistake.

Example fix

// before
{ "version": "1", "projects": {} }
// after
{ "version": 1, "projects": {} }
Defensive patterns

Strategy: validation

Validate before calling

const parsed = JSON.parse(await readFile('angular.json', 'utf8'));
if (parsed.version !== 1) {
  throw new Error(`Unsupported workspace version: ${JSON.stringify(parsed.version)}; expected numeric 1`);
}

Type guard

function isSupportedWorkspaceVersion(ws: unknown): ws is { version: 1 } {
  return typeof ws === 'object' && ws !== null
    && (ws as { version?: unknown }).version === 1;
}

Try / catch

try {
  const ws = await readWorkspace('angular.json', host);
} catch (e) {
  if (e.message.startsWith('Invalid format version detected')) {
    console.error('Set "version": 1 (numeric, unquoted) in angular.json, or upgrade the tooling that produced the file.');
  } else throw e;
}

Prevention

When it happens

Trigger: angular.json containing "version": 2 (or a string "1", null, etc.) passed to readJsonWorkspace; note that string "1" !== numeric 1 and also fails.

Common situations: File edited by a newer tool or hand-updated to a hypothetical v2; version value accidentally quoted ("version": "1") making it a string; config generators emitting a wrong version constant.

Related errors


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