Skip to content
Latchkey

Storybook addon "Cannot find module '@storybook/...'" in CI

Node could not resolve a @storybook/... package that your config or a story imports. On a clean CI runner this almost always means the package is missing from package.json or the lockfile.

What this error means

The build throws "Error: Cannot find module '@storybook/addon-interactions'" (or another Storybook package) even though it runs locally.

storybook
Error: Cannot find module '@storybook/addon-interactions'
Require stack:
- /home/runner/work/app/app/.storybook/main.ts

Common causes

The package is not in package.json

It was installed locally but never saved, so npm ci on the runner never brings it in.

A stale lockfile missing the dependency

The lockfile predates adding the addon, so a locked install omits it.

How to fix it

Install and lock the missing package

  1. Add the exact @storybook/... package the stack trace names.
  2. Match its major to your Storybook version.
  3. Commit the updated lockfile so npm ci installs it.
Terminal
npm install -D @storybook/addon-interactions@^8
git add package-lock.json

Use a clean install to reproduce CI locally

Delete node_modules and run the locked install to surface the missing package before pushing.

Terminal
rm -rf node_modules
npm ci
npm run build-storybook

How to prevent it

  • Always npm install -D addons so they land in package.json.
  • Commit the lockfile in the same change as the addon.
  • Reproduce CI with npm ci after removing node_modules.

Related guides

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