{"record":{"id":"fa9ea7d0619a3034","repo":"angular/angular-cli","slug":"workspace-config-file-cannot-be-loaded-configpa","errorCode":null,"errorMessage":"Workspace config file cannot be loaded: ${configPath}","messagePattern":"Workspace config file cannot be loaded: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/angular/cli/src/utilities/config.ts","lineNumber":210,"sourceCode":"      );\n\n      cachedWorkspaces.set(level, globalWorkspace);\n\n      return globalWorkspace;\n    }\n\n    cachedWorkspaces.set(level, undefined);\n\n    return undefined;\n  }\n\n  try {\n    const workspace = await AngularWorkspace.load(configPath);\n    cachedWorkspaces.set(level, workspace);\n\n    return workspace;\n  } catch (error) {\n    throw new Error(`Workspace config file cannot be loaded: ${configPath}`, { cause: error });\n  }\n}\n\n/**\n * This method will load the workspace configuration in raw JSON format.\n * When `level` is `global` and file doesn't exists, it will be created.\n *\n * NB: This method is intended to be used only for `ng config`.\n */\nexport async function getWorkspaceRaw(\n  level: 'local' | 'global' = 'local',\n): Promise<[JSONFile | null, string | null]> {\n  let configPath = level === 'local' ? await projectFilePath() : globalFilePath();\n\n  if (!configPath) {\n    if (level === 'global') {\n      configPath = defaultGlobalFilePath;\n      // Config doesn't exist, force create it.","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/utilities/config.ts#L192-L228","documentation":"The CLI's config layer (`getWorkspace`) loads an `angular.json`/`.angular.json` workspace file via `AngularWorkspace.load` and caches it per level (project/global). Any failure while reading or parsing that file is caught and rethrown with this message, with the original error attached as `cause`. It indicates the workspace config file exists (or was resolved) but could not be loaded.","triggerScenarios":"Any CLI command that resolves workspace configuration (via `wksp`, `globalWorkspace`, `workspace`, `globalOptions`) where `AngularWorkspace.load(configPath)` throws — typically invalid JSON, a schema mismatch, or an unreadable file.","commonSituations":"Hand-edited `angular.json` with a JSON syntax error (trailing comma, comments); file truncated by a bad merge; schema-version mismatch after upgrading the CLI; permission problems on the config file.","solutions":["Inspect `error.cause` for the underlying parse/load failure and fix that line in `angular.json`.","Validate `angular.json` with a JSON linter: `npx jsonlint angular.json` or `jq . angular.json > /dev/null`.","Restore the file: `git checkout -- angular.json`, or regenerate with `ng new` in a scratch dir and diff.","Confirm the file is readable by the current user and that you are running the CLI from inside the workspace root."],"exampleFix":"// before\n{\"projects\": {\"app\": {\"root\": \"\",}},  // trailing comma -> parse error\n// after\n{\"projects\": {\"app\": {\"root\": \"\"}}}","handlingStrategy":"try-catch","validationCode":"import { readFile } from 'node:fs/promises';\ntry {\n  JSON.parse(await readFile('angular.json', 'utf8'));\n} catch (e) {\n  throw new Error('angular.json is missing or invalid; fix before running the CLI.', { cause: e });\n}","typeGuard":"function isWorkspaceLoadError(e: unknown): e is Error {\n  return e instanceof Error && e.message.startsWith('Workspace config file cannot be loaded:');\n}","tryCatchPattern":"try {\n  await runNgCommand();\n} catch (e: any) {\n  if (e instanceof Error && e.message.startsWith('Workspace config file cannot be loaded')) {\n    console.error('Root cause:', e.cause); // inspect and fix angular.json\n  } else { throw e; }\n}","preventionTips":["Validate angular.json in CI (jq . angular.json) before running CLI commands.","Avoid hand-editing angular.json without re-validating JSON syntax.","Resolve merge conflicts in angular.json carefully and re-parse afterwards.","Keep @angular/cli and workspace schema versions in sync."],"tags":["config","angular-cli","json","workspace"],"backgroundTag":"config-file-unreadable","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}