Skip to content
Latchkey

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.

tsc
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:12

Common 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

  1. Delete cached build info and node_modules locally.
  2. Run the same yarn tsc the CI uses.
  3. Fix each reported "error TS" before pushing.
Terminal
rm -rf node_modules dist-types
yarn install --immutable
yarn tsc

Add the missing dependency or types

If the error is TS2307, add the package (and its @types if needed) to the workspace that imports it.

Terminal
yarn --cwd packages/app add @backstage/plugin-catalog

How to prevent it

  • Run a clean yarn tsc in 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.

Related guides

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