Cannot find module node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/interopRequireDefault
See original GitHub issueDescribe 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:
- Use npm to install all dependencies
- Setup CRA + storybook using this instruction https://www.learnstorybook.com/react/en/get-started/
- 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
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.
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (3 by maintainers)
Top GitHub 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
–clearCache also worked for me