{"record":{"id":"0aa4bbcd09f4eebe","repo":"angular/angular-cli","slug":"unknown-format-version-specifier-not-found","errorCode":null,"errorMessage":"Unknown format - version specifier not found.","messagePattern":"Unknown format - version specifier not found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/core/src/workspace/json/reader.ts","lineNumber":59,"sourceCode":"export async function readJsonWorkspace(\n  path: string,\n  host: WorkspaceHost,\n  options: JsonWorkspaceOptions = {},\n): Promise<WorkspaceDefinition> {\n  const raw = await host.readFile(path);\n  if (raw === undefined) {\n    throw new Error('Unable to read workspace file.');\n  }\n\n  const ast = parseTree(raw, undefined, { allowTrailingComma: true, disallowComments: false });\n  if (ast?.type !== 'object' || !ast.children) {\n    throw new Error('Invalid workspace file - expected JSON object.');\n  }\n\n  // Version check\n  const versionNode = findNodeAtLocation(ast, ['version']);\n  if (!versionNode) {\n    throw new Error('Unknown format - version specifier not found.');\n  }\n  const version = versionNode.value;\n  if (version !== 1) {\n    throw new Error(`Invalid format version detected - Expected:[ 1 ] Found: [ ${version} ]`);\n  }\n\n  const context: ParserContext = {\n    host,\n    metadata: new JsonWorkspaceMetadata(path, ast, raw),\n    trackChanges: true,\n    unprefixedWorkspaceExtensions: new Set([\n      ...ANGULAR_WORKSPACE_EXTENSIONS,\n      ...(options.allowedWorkspaceExtensions ?? []),\n    ]),\n    unprefixedProjectExtensions: new Set([\n      ...ANGULAR_PROJECT_EXTENSIONS,\n      ...(options.allowedProjectExtensions ?? []),\n    ]),","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/core/src/workspace/json/reader.ts#L41-L77","documentation":"The reader requires a top-level 'version' property to identify the workspace format. If the parsed object has no 'version' node (findNodeAtLocation returns falsy), it throws this Error. The version field is the format contract of angular.json.","triggerScenarios":"angular.json missing the \"version\": 1 line (hand-written file, trimmed config, tool output that omitted it); a custom workspace-like file passed to readWorkspace.","commonSituations":"Writing angular.json manually and forgetting the version key; tools that regenerate only the 'projects' section; copying a partial example from docs.","solutions":["Add \"version\": 1 to the top level of the workspace file.","Regenerate the file with Angular CLI (ng generate config) to get a valid skeleton.","Restore from git if the version field was accidentally deleted."],"exampleFix":"// before\n{\n  \"projects\": { \"app\": { \"root\": \"apps/app\" } }\n}\n// after\n{\n  \"version\": 1,\n  \"projects\": { \"app\": { \"root\": \"apps/app\" } }\n}","handlingStrategy":"validation","validationCode":"const parsed = JSON.parse(await readFile('angular.json', 'utf8'));\nif (!('version' in parsed)) {\n  throw new Error('angular.json is missing the required \"version\": 1 field');\n}","typeGuard":"function hasVersionField(ws: unknown): ws is { version: unknown } {\n  return typeof ws === 'object' && ws !== null && 'version' in ws;\n}","tryCatchPattern":"try {\n  const ws = await readWorkspace('angular.json', host);\n} catch (e) {\n  if (e.message.includes('version specifier not found')) {\n    console.error('Add \"version\": 1 to the top level of angular.json.');\n  } else throw e;\n}","preventionTips":["Always include \"version\": 1 in hand-written workspace files","Use `ng generate config` to create a valid skeleton instead of writing from scratch","Add a JSON schema check (angular.json schema) in CI to catch missing required fields"],"tags":["workspace","schema-validation","missing-field","angular-devkit"],"backgroundTag":"missing-required-field","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}