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

  1. Verify the tsconfig path passed to the migration (ng update / update-tool) exists relative to the workspace root; create or correct it.
  2. Check for typos or an incorrect project configuration pointing at a nonexistent tsconfig.
  3. 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

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


AI-assisted analysis of angular/components@0411926e7d (2026-08-31). Data as JSON: /api/errors/7ddb970e531740bd. Report an issue: GitHub.