Backstage "yarn tsc" error TS type check fails in CI
Backstage runs a full type check with yarn tsc (backstage-cli repo type-check) before building. CI does a clean check with no cached .tsbuildinfo, so type errors that a local incremental build skipped surface here.
What this error means
The type check step fails with one or more "error TS2307: Cannot find module" or "error TS2345" lines and a non-zero exit, even when the app runs locally.
packages/app/src/App.tsx:12:24 - error TS2307: Cannot find module
'@backstage/plugin-catalog' or its corresponding type declarations.
Found 1 error in packages/app/src/App.tsx:12Common causes
A stale local build hid the error
Local incremental builds reuse cached type info, so a broken import or type only fails on the clean CI check.
A missing dependency or type package
The referenced module is not installed or lacks type declarations, which a clean check flags as TS2307.
How to fix it
Reproduce the clean type check locally
- Delete cached build info and node_modules locally.
- Run the same
yarn tscthe CI uses. - Fix each reported "error TS" before pushing.
rm -rf node_modules dist-types
yarn install --immutable
yarn tscAdd the missing dependency or types
If the error is TS2307, add the package (and its @types if needed) to the workspace that imports it.
yarn --cwd packages/app add @backstage/plugin-catalogHow to prevent it
- Run a clean
yarn tscin CI before build, matching a from-scratch check locally. - Keep every imported module declared as a dependency.
- Do not rely on incremental .tsbuildinfo to pass type checks.