Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module 'babel-preset-react'

This is my first React Native project. The repo is here.

When I start up expo, I get the error:

Cannot find module 'babel-preset-react'

Among others, it has these dependencies:

"expo": "^32.0.0",
"react": "16.8.4",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.1.tar.gz",
"@babel/core": "7.3.4",
"babel-core": "^7.0.0-bridge.0",
"@babel/preset-react": "^7.0.0",

I found these four libraries in my app's /node_modules that each contain a dev dependency on "babel-preset-react":

hoist-non-react-statics, prop-types, react-input-autosize and react-proxy.

None of these have newer versions that depend on "@babel/preset-react".

like image 258
Dan Cancro Avatar asked Mar 08 '19 00:03

Dan Cancro


2 Answers

I had this a few, every time I install a new module/plugin. My solution has been to delete node_modules folder and yarn install or npm install.

It stops the error. I'm not sure is the right solution (would be interested to know if it is), but works.

like image 50
Luiz Henrique Pinto Avatar answered Oct 12 '22 07:10

Luiz Henrique Pinto


This seems to be an issue to do with an expo project being in a bad state.

Expo is an express set of libs with the goal of simplifying development, but it is not compatible with most react native examples in the wild.

After further review, it looks like you may have followed a regular react native example in an Expo based project, without first ejecting.

like image 22
Steven Stark Avatar answered Oct 12 '22 05:10

Steven Stark