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
- Run the production Storybook build to get the exact failing module.
- Fix the import path and case.
Terminal
npm run build-storybookVerify framework and builder config
- Confirm
.storybook/mainnames 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
Storybook "Module not found" - Fix in CIFix "Module not found" inside a Storybook build in CI - a missing dependency, an unresolved alias, or a path/…
Storybook "command not found" - Fix in CIFix "storybook: command not found" in CI - the Storybook CLI is not installed, dev dependencies were skipped,…
Storybook Addon Incompatible Version - Fix in CIFix Storybook addon version mismatches in CI - an addon on a different major than the Storybook core fails to…