Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'babel-preset-react-app' #84

Closed
FezVrasta opened this issue Sep 1, 2017 · 18 comments
Closed

Cannot find module 'babel-preset-react-app' #84

FezVrasta opened this issue Sep 1, 2017 · 18 comments

Comments

@FezVrasta
Copy link
Contributor

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?

@timarney
Copy link
Owner

timarney commented Sep 2, 2017

What version of react scripts are you using?

@FezVrasta
Copy link
Contributor Author

Latest

@RIP21
Copy link

RIP21 commented Sep 4, 2017

@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.

@FezVrasta
Copy link
Contributor Author

FezVrasta commented Sep 4, 2017

I already tried to clean the node_modules folder, I tried both yarn and npm and I'm on latest Node.

I think this module should list babel-preset-react-app in its dependencies since it requires it to work... Or at least, peerDependencies

@timarney
Copy link
Owner

timarney commented Sep 8, 2017

Curious can you try that 1.2.6 release and see what happens?

@FezVrasta
Copy link
Contributor Author

FezVrasta commented Sep 8, 2017

I get the same error (only when I run yarn test).

I'm using Yarn 1.x now, just to let you know.

@Guria
Copy link
Collaborator

Guria commented Sep 8, 2017

Try delete node_modules and lock files then install deps again

@FezVrasta
Copy link
Contributor Author

FezVrasta commented Sep 8, 2017

Already tried, anyway, it's conceptually wrong to refer to a dependency without having it defined in your package.json.

@aaron-harvey
Copy link

@Guria removing the lock file, in addition to node_modules worked for me (yarn v1.0.1). Thanks.

@FezVrasta
Copy link
Contributor Author

I tried again with a fresh project and it worked, so weird. I guess it's solved

@tkh44
Copy link

tkh44 commented Sep 12, 2017

I was able to resolve this by doing what @Guria suggested

delete node_modules and lock files then install deps again

AND running

jest --resetModules

@congson0710
Copy link

@Guria 's solution works !

@jcabrerazuniga
Copy link

How can we lock files?

@dawnmist
Copy link
Collaborator

dawnmist commented Nov 1, 2018

@jcabrerazuniga Sorry, it means to delete the files that the package managers create (that have lock in their name) that keep track of the actual versions of packages installed. If you use yarn, delete yarn.lock. If you use npm, delete package-lock.json.

@Pomelo1213
Copy link

thx. it`s work

@AuthorOfTheSurf
Copy link

I had to update my .babelrc from

{
  "presets": ["env", "react"]
}

to

{
  "presets": ["@babel/env", "@babel/react"]
}

to resolve this issue.

@JackWong992
Copy link

I had to update my .babelrc from

{
  "presets": ["env", "react"]
}

to

{
  "presets": ["@babel/env", "@babel/react"]
}

to resolve this issue.

Thank you, I solved my problem with your help.

@mvaden
Copy link

mvaden commented Jun 12, 2019

For me, removing yarn.lock did the trick since I'm already using NPM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests