Skip to content
Latchkey

TS6059: File is not under rootDir - in CI

A compiled file lives outside the configured rootDir, so tsc cannot compute a consistent output structure.

What this error means

Type-checking/build fails with TS6059 naming a file outside rootDir, often an imported file from a sibling package.

tsc
error TS6059: File '/app/shared/types.ts' is not under 'rootDir' '/app/src'. 'rootDir' is expected to contain all source files.

Common causes

How to fix it

Widen rootDir or restructure includes

  1. Set rootDir to a directory containing all compiled sources, or remove it to let TS infer
tsconfig.json
{
  "compilerOptions": { "rootDir": "." }
}

Use project references for shared code

  1. Build shared packages separately and reference them rather than importing source across roots

How to prevent it

  • Keep rootDir broad enough for all sources, or use project references for cross-package imports.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →