storybook: Cannot find module node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/interopRequireDefault

Describe the bug Running npm run test command results in error: Cannot find module ‘/Users/yankovskyandrey/Code/cra-sb-storyshots-bug/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/interopRequireDefault’ from ‘Storyshots.test.js’

To Reproduce Steps to reproduce the behavior:

  1. Use npm to install all dependencies
  2. Setup CRA + storybook using this instruction https://www.learnstorybook.com/react/en/get-started/
  3. Add addon-storyshots and addon-storyshots-puppeteer by following their instructions

or just clone my repo https://github.com/Yankovsky/cra-sb-storyshots-bug and follow instructions inside

Expected behavior Everything works, tests run.

Screenshots http://s.csssr.ru/U02D248T6/2019-06-19-23-09-11-xjj9e_.jpg

Code snippets I pushed repo with that bug, just follow readme inside https://github.com/Yankovsky/cra-sb-storyshots-bug

System:

  • OS: MacOS
  • Device: Macbook Pro 2015
  • Framework: react
  • Addons: addon-actions, addon-links, addon-storyshots, addon-storyshots-puppeteer
  • Version: 5.1.8

Additional context This problem relates somehow to module resolution. npm installs @babel/runtime as a topmost dependency but as you can see on screenshot test command looks for @babel/runtime here node_modules/babel-preset-react-app/node_modules/@babel/runtime. Manually installing @babel/runtime as project dependency fixes the problem for some reason. Yarn installs @babel/runtime as babel-preset-react-app dependency so it works just fine.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

FWIW, what helped me was running jest with --clearCache. I suspect some outdated information was sitting there, that polluted all my tests.

See here for specifics