TS2688: Cannot find type definition file for - in CI
A name listed in compilerOptions.types (or referenced via /// reference types) has no installed @types package.
What this error means
Type-checking fails with TS2688 naming the type package it cannot find under typeRoots.
tsc
error TS2688: Cannot find type definition file for 'jest'.Common causes
How to fix it
Install the referenced types
- Install the @types package named in the types array
shell
npm i -D @types/jestRemove the stale types entry
- Delete unused names from compilerOptions.types
- Verify typeRoots includes node_modules/@types
tsconfig.json
{
"compilerOptions": {
"types": ["node"]
}
}How to prevent it
- Keep compilerOptions.types in sync with installed @types packages and prune entries you remove.
Related guides
TS2580: Cannot find name 'process' - in CIFix "error TS2580: Cannot find name 'process'" (and require/__dirname/Buffer) when tsc runs in CI - install @…
TS7016: Could not find a declaration file for module - in CIFix "error TS7016: Could not find a declaration file for module 'x'. '...' implicitly has an 'any' type" when…
TS2307: Cannot find module - in CIFix "error TS2307: Cannot find module 'x' or its corresponding type declarations" when tsc runs in CI - a mis…