TS6059: File is not under 'rootDir' TypeScript Origin: On your device OSI layer 7 · Application Last updated 5 Nov 2026

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

A source file lives outside the configured rootDir, so tsc can't preserve the output structure.

Exact message you may see error TS6059: File '/app/shared/util.ts' is not under 'rootDir' '/app/src'. 'rootDir' is expected to contain all source files.File is not under 'rootDir'. 'rootDir' is expected to contain all source files.TS6059 rootDirerror TS6307: File is not listed within the file list of project. Projects must list all files or use an 'include' pattern.
Seen on: TypeScript

Meaning

Remove/adjust rootDir (let TS compute it), move shared code under it, include the right folders, or use project references for packages (composite: true). In monorepos prefer references or building packages separately and importing their built output.

Common causes

  • rootDir: "src" but importing from ../shared
  • Monorepo imports outside the package
  • include listing outside folders
  • Path aliases pointing outside rootDir
  • Tests outside src

⚡ Quick fix

  1. Remove rootDir or set it to the common ancestor
  2. Use TypeScript project references (references)
  3. Move shared files under rootDir or build them as a package

Detailed fix by platform

TypeScript

  1. { "compilerOptions": { "composite": true, "rootDir": "." }, "references": [{ "path": "../shared" }] }

How to diagnose

  1. rootDir — Contains all?
  2. Imports — Outside?
  3. References — Used?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

Cannot find module './App.vue' or its corresponding type declarations — TypeScript: error TS2307: Cannot find module './App.vue' or its corresponding type declarations. (Vue)Cannot find module '.…TS17004: Cannot use JSX unless the '--jsx' flag is provided — TypeScript: error TS17004: Cannot use JSX unless the '--jsx' flag is provided. (TypeScript)TS17004: Cannot use J…TS2307 — TS2307: Cannot find module 'x' or its corresponding type declarations. (Node.js)TS2307TS2688: Cannot find type definition file for 'x' — TypeScript: error TS2688: Cannot find type definition file for 'node'. (TypeScript)TS2688: Cannot find t…TS2792: Cannot find module — did you mean to set the 'moduleResolution' option to 'nodenext' — TypeScript: error TS2792: Cannot find module 'x'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? (TypeScript)TS2792: Cannot find m…TS2802: Type can only be iterated through when using the '--downlevelIteration' flag — TypeScript: error TS2802: Type 'Set<string>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher (TypeScript)TS2802: Type can only…TS5083: Cannot read file tsconfig.json / extends not found — TypeScript: error TS5083: Cannot read file '/app/tsconfig.json'. / error TS6053: File 'tsconfig.base.json' not found (TypeScript)TS5083: Cannot read f…TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or 'es2015' or later — TypeScript: error TS5095 (TypeScript)TS5095: Option 'bundl…TS6059: F…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.