Storybook "Module not found" - Fix in CI
Storybook's builder walked a story import and could not resolve it. The package is missing, an alias is not mirrored into Storybook, or the path/case is wrong.
What this error means
The build reports Module not found: Error: Can't resolve '<module>' from a story or a component it imports.
webpack
ModuleNotFoundError: Module not found:
Error: Can't resolve '@/components/Button' in '/app/src/stories'Common causes
Alias not configured for Storybook
A @/ alias works in the app build but is not mirrored into .storybook/main viteFinal/webpackFinal.
Missing dependency or wrong path
The imported package is not installed, or the relative path/case is wrong on the Linux runner.
How to fix it
Mirror app aliases into Storybook
- Add the same alias to the Storybook builder config.
.storybook/main.js
// .storybook/main.js (Vite builder)
viteFinal: async (config) => {
config.resolve.alias['@'] = path.resolve(__dirname, '../src');
return config;
},Install missing deps and fix the path
- Install the package, verify the file exists with exact casing.
Terminal
npm install <package>
ls -la src/components/Button.tsxHow to prevent it
- Keep Storybook builder aliases in sync with the app build and tsconfig paths.
- Run Storybook builds in CI to catch resolution drift.
Related guides
Storybook "build-storybook failed" - Fix in CIFix a failing Storybook static build in CI - a broken story import, a missing addon, or a builder config erro…
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…