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
- Set "version": 1 (numeric, unquoted) at the top level of the workspace file.
- If the file came from a newer tool version, use a matching/newer version of the tooling that supports that format.
- 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
- Ensure the version value is the number 1, not the string "1" — strict !== comparison fails on strings
- Do not bump the version field manually hoping to unlock features
- Match tool versions: files from newer generators need a tooling version that supports their format
- Validate angular.json against the official schema in CI
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
- Unknown format - version specifier not found.
- Project name already exists.
- "${name}" must be a JSON value.
- Project name must be a valid npm package name.
- Target name already exists.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/1467141b17490bd9.
Report an issue: GitHub.