angular/components · error · TsconfigParseError
Tsconfig cannot not be read: ${tsconfigPath}
Error message
Tsconfig cannot not be read: ${tsconfigPath} What it means
parseTsconfigFile throws a TsconfigParseError with this message when the given tsconfig path does not exist in the workspace FileSystem (fileExists check fails). The migration tool needs the tsconfig to build a TypeScript Program and cannot proceed without it. Note the message has a typo ('cannot not be read') but means 'cannot be read'.
Source
Thrown at src/cdk/schematics/update-tool/utils/parse-tsconfig.ts:31
import {formatDiagnostics} from './diagnostics';
/** Code of the error raised by TypeScript when a tsconfig doesn't match any files. */
const NO_INPUTS_ERROR_CODE = 18003;
/** Class capturing a tsconfig parse error. */
export class TsconfigParseError extends Error {}
/**
* Attempts to parse the specified tsconfig file.
*
* @throws {TsconfigParseError} If the tsconfig could not be read or parsed.
*/
export function parseTsconfigFile(
tsconfigPath: WorkspacePath,
fileSystem: FileSystem,
): ts.ParsedCommandLine {
if (!fileSystem.fileExists(tsconfigPath)) {
throw new TsconfigParseError(`Tsconfig cannot not be read: ${tsconfigPath}`);
}
const {config, error} = ts.readConfigFile(
tsconfigPath,
p => fileSystem.read(fileSystem.resolve(p))!,
);
// If there is a config reading error, we never attempt to parse the config.
if (error) {
throw new TsconfigParseError(formatDiagnostics([error], fileSystem));
}
const parsed = ts.parseJsonConfigFileContent(
config,
new FileSystemHost(fileSystem),
dirname(tsconfigPath),
{},
);View on GitHub (pinned to 0411926e7d)
Solutions
- Verify the tsconfig path passed to the migration (ng update / update-tool) exists relative to the workspace root; create or correct it.
- Check for typos or an incorrect project configuration pointing at a nonexistent tsconfig.
- If the project uses a non-standard layout, ensure the expected tsconfig is present or the path option is adjusted to the actual file.
Example fix
// before (path doesn't exist)
parseTsconfigFile('projects/app/tsconfig.json' as WorkspacePath, fileSystem);
// after (ensure file exists, or guard first)
const path = 'tsconfig.json' as WorkspacePath;
if (!fileSystem.fileExists(path)) {
throw new Error(`tsconfig missing at ${path}; check your project configuration`);
}
parseTsconfigFile(path, fileSystem); Defensive patterns
Strategy: validation
Validate before calling
import {existsSync} from 'fs';
if (!existsSync(tsconfigPath)) {
console.error(`tsconfig not found at ${tsconfigPath}; check your --tsconfig-path option`);
process.exit(1);
} Type guard
function tsconfigExists(path: string, fs: FileSystem): path is WorkspacePath {
return fs.fileExists(path as WorkspacePath);
} Try / catch
try {
const parsed = parseTsconfigFile(path, fileSystem);
} catch (e) {
if (e instanceof TsconfigParseError && /cannot not be read/.test(e.message)) {
console.error(`tsconfig missing: ${e.message}`);
} else {
throw e;
}
} Prevention
- Always confirm the tsconfig path relative to the workspace root before running migrations.
- Pass an explicit tsconfig path option if your workspace layout is non-standard.
- Keep tsconfig.json files committed so they aren't lost between checkouts.
When it happens
Trigger: Calling parseTsconfigFile(tsconfigPath, fileSystem) where fileSystem.fileExists(tsconfigPath) returns false — i.e. the passed path points to a nonexistent file, or a directory instead of a tsconfig file.
Common situations: A schematic/migration was configured with a wrong tsconfig path (e.g. typos, wrong project target), the tsconfig was renamed or deleted, the migration runs on a workspace layout where the expected tsconfig (e.g. tsconfig.json at project root) doesn't exist, or the path is resolved against the wrong workspace root.
Related errors
- formatDiagnostics([error], fileSystem)
- formatDiagnostics(errors, fileSystem)
- Could not find file for path: ${path}
- Module not found: ${modulePath}
- Could not read Angular module file: ${modulePath}
AI-assisted analysis of angular/components@0411926e7d (2026-08-31).
Data as JSON: /api/errors/7ddb970e531740bd.
Report an issue: GitHub.