react-app-rewired: Cannot find module 'babel-preset-react-app'
I get this error when I run the tests:
● Test suite failed to run
Cannot find module 'babel-preset-react-app'
at Function.Module._resolveFilename (module.js:485:15)
at Function.resolve (internal/module.js:18:19)
at Object.<anonymous> (node_modules/react-app-rewired/config/jest/babelTransform.js:21:21)
Actually, I can’t seem to find babel-preset-react-app inside my node_modules root folder. I see it’s located inside node_modules/react-scripts/node_modules/babel-preset-react-app.
Maybe create-react-app changed the way the dependency is required?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 18 (7 by maintainers)
Try delete node_modules and lock files then install deps again
I had to update my
.babelrcfromto
to resolve this issue.
I was able to resolve this by doing what @Guria suggested
delete node_modules and lock files then install deps againAND running
jest --resetModulesThank you, I solved my problem with your help.
@jcabrerazuniga Sorry, it means to delete the files that the package managers create (that have
lockin their name) that keep track of the actual versions of packages installed. If you use yarn, deleteyarn.lock. If you use npm, deletepackage-lock.json.@FezVrasta sounds as stupid suggestion but really try to remove node_modules and install them again. Or try to use yarn instead of npm. Also, make sure that your node version is at least 6. And if anything of that helps, just install this preset putting it in package.json. Don’t know what can be a reason really. Sometimes there is a packages on npm which include into dependencies some Babel stuff and other development only dependencies by mistake, causing conflicts with react-scripts defaults. Be sure that you don’t have any conflicts.