Storybook "Cannot find module '@storybook/...'" in CI
Node could not resolve a @storybook/* package that your .storybook config or a story file imports. The framework, renderer, or addon package is missing from the runner's installed dependencies.
What this error means
Running storybook build or storybook dev fails with "Error: Cannot find module '@storybook/react'" (or another @storybook package) before any stories load.
Error: Cannot find module '@storybook/react'
Require stack:
- /home/runner/work/app/app/.storybook/main.js
at Function._resolveFilename (node:internal/modules/cjs/loader:1145:15)Common causes
The package is not in package.json
A renderer or framework package (@storybook/react, @storybook/react-vite) is imported by config but was never added as a dependency, so a clean CI install never fetches it.
A version skew after a Storybook major upgrade
After upgrading the core, the renderer package name changed, leaving config pointing at a package that is no longer installed.
How to fix it
Install the exact framework package
- Read which
@storybook/*package the require stack names. - Add it to devDependencies and reinstall.
- Re-run the Storybook build to confirm it resolves.
npm install --save-dev @storybook/react @storybook/react-viteKeep all @storybook packages on one version
Mixed Storybook versions cause resolution failures. Align core, renderer, and addons to the same version.
npx storybook@latest upgradeHow to prevent it
- Declare every Storybook framework and addon package in devDependencies.
- Use
storybook upgradeso all @storybook packages stay on one version. - Run a clean install in CI so missing packages surface, not local leftovers.