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.

Frequently asked questions

What causes "Storybook build failed"?
A story imports a component path that does not exist or has the wrong case on Linux.
How do I fix Storybook build failed?
Reproduce the build locally

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card