{"record":{"id":"e6f4c8dcebd0ffb0","repo":"angular/angular-cli","slug":"path-path-does-not-exist-e6f4c8","errorCode":null,"errorMessage":"Path \"${path}\" does not exist.","messagePattern":"Path \"(.+?)\" does not exist\\.","errorType":"exception","errorClass":"FileDoesNotExistException","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/schematics/tools/file-system-utility.ts","lineNumber":20,"sourceCode":" * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport { JsonValue } from '@angular-devkit/core';\nimport { ParseError, parse, printParseErrorCode } from 'jsonc-parser';\nimport { readFileSync } from 'node:fs';\nimport { FileDoesNotExistException } from '../src/exception/exception';\n\nexport function readJsonFile(path: string): JsonValue {\n  let data;\n  try {\n    data = readFileSync(path, 'utf-8');\n  } catch (e) {\n    if (e && typeof e === 'object' && 'code' in e && e.code === 'ENOENT') {\n      throw new FileDoesNotExistException(path);\n    }\n    throw e;\n  }\n\n  const errors: ParseError[] = [];\n  const content = parse(data, errors, { allowTrailingComma: true }) as JsonValue;\n\n  if (errors.length) {\n    const { error, offset } = errors[0];\n    throw new Error(\n      `Failed to parse \"${path}\" as JSON AST Object. ${printParseErrorCode(\n        error,\n      )} at location: ${offset}.`,\n    );\n  }\n\n  return content;\n}","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/schematics/tools/file-system-utility.ts#L2-L38","documentation":"readJsonFile wraps readFileSync; when the file is missing, Node returns ENOENT and this function converts it into FileDoesNotExistException with the requested path. It exists so callers get a devkit-typed error instead of a raw Node error.","triggerScenarios":"Calling readJsonFile(path) (directly or via collection/schematic loading in _resolveCollectionPath/createSchematicDescription/jsonValue) when the file does not exist on disk.","commonSituations":"collection.json or schema.json path typo; schematic deleted or renamed but still referenced from collection.json; running the generator in a different working directory so relative paths no longer resolve; package published without JSON files included.","solutions":["Check the path in the error message and verify the file exists (ls the directory).","Fix the path reference in collection.json (or the caller) to the actual file location.","If the file belongs to a package, reinstall it or rebuild/link your local collection.","Run from the intended working directory if relative paths are used."],"exampleFix":"// before\n\"schema\": \"./schema.json\" // file actually at ./schemas/schema.json, throws ENOENT\n// after\n\"schema\": \"./schemas/schema.json\"","handlingStrategy":"try-catch","validationCode":"import { existsSync } from 'fs';\nif (!existsSync(jsonPath)) {\n  throw new Error(`Refusing to load: ${jsonPath} does not exist`);\n}","typeGuard":null,"tryCatchPattern":"import { FileDoesNotExistException } from '@angular-devkit/schematics';\ntry {\n  const json = readJsonFile(jsonPath);\n} catch (e) {\n  if (e instanceof FileDoesNotExistException) {\n    console.error(`Missing file: ${e.file}. Check paths in collection.json.`);\n    process.exitCode = 1;\n  } else throw e;\n}","preventionTips":["Use path.join(__dirname, ...) instead of process.cwd()-relative paths so files resolve regardless of where the tool runs.","Ensure JSON assets (collection.json, schema.json) are copied in the build and included in the npm package.","Run CI from a clean checkout to catch missing/rename files before release."],"tags":["filesystem","json","missing-file"],"backgroundTag":"file-does-not-exist","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}