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
- 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.
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
- 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.
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
- Invalid config found at ${workspace.filePath}. CLI should be
- Access denied: path '${path}' is outside allowed roots.
- Failed to access path: ${fileOrDirPath}
- Workspace path does not exist: ${workspacePathInput}. You ca
- No angular.json found at ${workspacePathInput}. You can use
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/e6f4c8dcebd0ffb0.
Report an issue: GitHub.