tsc --noEmit passes locally but fails in CI
tsc reports errors in CI that you do not see locally, which points at an environment difference, not a flaky check.
What this error means
npm run type-check is clean on your machine but the same command fails on the runner with real TS errors.
tsc
Local: tsc --noEmit -> 0 errors
CI: tsc --noEmit -> error TS2307: Cannot find module ... (and others)Common causes
How to fix it
Pin and use the lockfile TypeScript
- Install from the lockfile and run the local tsc, not a global one
shell
npm ci
npx tsc --version
npx tsc --noEmitClear caches and check casing
- Delete stale .tsbuildinfo and re-run
- Match import casing to filenames for case-sensitive runners
shell
rm -f tsconfig.tsbuildinfoHow to prevent it
- Pin TypeScript in devDependencies, run tsc via npx from the lockfile, and enable forceConsistentCasingInFileNames.
Frequently asked questions
What causes "tsc passes locally, fails in CI"?
npm run type-check is clean on your machine but the same command fails on the runner with real TS errors.
How do I fix tsc passes locally, fails in CI?
Pin and use the lockfile TypeScript
Related guides
TS2307: Cannot find module - in CIFix "error TS2307: Cannot find module 'x' or its corresponding type declarations" when tsc runs in CI - a mis…
TS5023: Unknown compiler option - in CIFix "error TS5023: Unknown compiler option 'x'" when tsc runs in CI - a typo, a removed option, or an option…
Type checking is slow in CI (tsc)Fix slow tsc type-checking in CI - enable incremental builds, project references, and skipLibCheck, and run o…