angular/angular-cli · error · FileDoesNotExistException

Path "${path}" does not exist.

Error message

Path "${path}" does not exist.

What it means

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.

Source

Thrown at packages/angular_devkit/schematics/tools/file-system-utility.ts:20

 * @license
 * Copyright Google LLC All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.dev/license
 */

import { JsonValue } from '@angular-devkit/core';
import { ParseError, parse, printParseErrorCode } from 'jsonc-parser';
import { readFileSync } from 'node:fs';
import { FileDoesNotExistException } from '../src/exception/exception';

export function readJsonFile(path: string): JsonValue {
  let data;
  try {
    data = readFileSync(path, 'utf-8');
  } catch (e) {
    if (e && typeof e === 'object' && 'code' in e && e.code === 'ENOENT') {
      throw new FileDoesNotExistException(path);
    }
    throw e;
  }

  const errors: ParseError[] = [];
  const content = parse(data, errors, { allowTrailingComma: true }) as JsonValue;

  if (errors.length) {
    const { error, offset } = errors[0];
    throw new Error(
      `Failed to parse "${path}" as JSON AST Object. ${printParseErrorCode(
        error,
      )} at location: ${offset}.`,
    );
  }

  return content;
}

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Check the path in the error message and verify the file exists (ls the directory).
  2. Fix the path reference in collection.json (or the caller) to the actual file location.
  3. If the file belongs to a package, reinstall it or rebuild/link your local collection.
  4. Run from the intended working directory if relative paths are used.

Example fix

// before
"schema": "./schema.json" // file actually at ./schemas/schema.json, throws ENOENT
// after
"schema": "./schemas/schema.json"
Defensive patterns

Strategy: try-catch

Validate before calling

import { existsSync } from 'fs';
if (!existsSync(jsonPath)) {
  throw new Error(`Refusing to load: ${jsonPath} does not exist`);
}

Try / catch

import { FileDoesNotExistException } from '@angular-devkit/schematics';
try {
  const json = readJsonFile(jsonPath);
} catch (e) {
  if (e instanceof FileDoesNotExistException) {
    console.error(`Missing file: ${e.file}. Check paths in collection.json.`);
    process.exitCode = 1;
  } else throw e;
}

Prevention

When it happens

Trigger: Calling readJsonFile(path) (directly or via collection/schematic loading in _resolveCollectionPath/createSchematicDescription/jsonValue) when the file does not exist on disk.

Common situations: 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.

Related errors


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