Skip to content
Latchkey

Backstage "Cannot find module @backstage/plugin-..." in CI

Node could not resolve a @backstage/plugin-* package at build or runtime. Either the package is not in package.json, install skipped it, or it was imported without being added as a dependency.

What this error means

The build or backend start fails with "Error: Cannot find module '@backstage/plugin-catalog-backend'" and a stack that points into your app or backend index file.

node
Error: Cannot find module '@backstage/plugin-catalog-backend'
Require stack:
- /app/packages/backend/dist/index.cjs.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:...)

Common causes

The plugin is imported but not a declared dependency

Code references the plugin, but it is missing from the workspace package.json, so it is never installed.

Install did not complete or the lockfile is out of date

A partial or cached install, or a yarn.lock that predates the added plugin, leaves the package absent from node_modules.

How to fix it

Add the plugin to the right workspace package

  1. Add the plugin dependency to the package that imports it (app or backend).
  2. Run install so the lockfile records it.
  3. Commit the updated yarn.lock and re-run CI.
Terminal
yarn --cwd packages/backend add @backstage/plugin-catalog-backend

Reinstall against a fresh lockfile

Ensure CI installs exactly what the lockfile pins so no plugin is silently missing.

Terminal
yarn install --immutable

How to prevent it

  • Add every imported plugin as a dependency of the workspace that uses it.
  • Commit yarn.lock so CI installs the full plugin set deterministically.
  • Use yarn install --immutable in CI to catch lockfile drift.

Related guides

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