Skip to content
Latchkey

Storybook "build-storybook failed" - Fix in CI

Storybook compiles every story and addon into a static site. Any story that fails to compile, or a builder misconfiguration, aborts the whole build-storybook run.

What this error means

The Storybook build exits non-zero with Build failed with errors and a stack pointing at a story file or the builder.

webpack
=> Failed to build the preview
SB_BUILDER-WEBPACK5_0003 (WebpackCompilationError):
Module not found: Error: Can't resolve './Button' in '/app/src/components'

Common causes

Broken story import

A story imports a component path that does not exist or has the wrong case on Linux.

Builder/preset misconfiguration

The .storybook/main config references a framework or builder that is not installed or set up correctly.

How to fix it

Reproduce the build locally

  1. Run the production Storybook build to get the exact failing module.
  2. Fix the import path and case.
Terminal
npm run build-storybook

Verify framework and builder config

  1. Confirm .storybook/main names an installed framework package.
.storybook/main.js
// .storybook/main.js
module.exports = { framework: { name: '@storybook/react-vite', options: {} } };

How to prevent it

  • Run build-storybook in CI on PRs so story breakage is caught before merge.
  • Develop on a case-sensitive filesystem to catch import-case bugs.

Related guides

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