14

I have created a React Native Project and I was trying to open that project in Expo XDE. It throws the following error:

Cannot find module ...\node_modules\expo\tools\LogReporter

Firstly I created a React Native project by cloning a KitchenSink Project. Link:

NativeBase-KitchenSink

When I started the project by issuing series of commands inside the project root directory:

npm install and then expo start

I saw that the app.json was also not proper, which was the following:

{
  "name": "NativebaseKitchenSink",
  "displayName": "NativebaseKitchenSink"
}

After issuing expo start react-native reported that the app.json is not to be found in the current directory.

[17:05:08] Starting project at D:\Projects\ReactNativeProjects\AwesomeProject [17:05:10] Error: Missing app.json. See https://docs.expo.io/ [17:05:10] Couldn't start project. Please fix the errors and restart the project. [17:05:10] Error: Couldn't start project. Please fix the errors and restart the project. at C:\xdl@51.4.0\src\Project.js:1565:11 at Generator.next () at step (C:\Users\hp\AppData\Roaming\npm\node_modules\expo-cli\node_modules\xdl\build\Project.js:2033:191) at C:\Users\hp\AppData\Roaming\npm\node_modules\expo-cli\node_modules\xdl\build\Project.js:2033:361 at process._tickCallback (internal/process/next_tick.js:68:7)

I changed app.json to:

{
  "expo": {
    "name": "AwesomeProject",
    "description": "A Kitchen Sink project.",
    "slug": "AwesomeProject",
    "privacy": "public",
    "sdkVersion": "30.0.0",
    "platforms": [
      "ios",
      "android"
    ],
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "package": "com.abhsax.first"
    },
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/logo.png",
    "splash": {
      "image": "./assets/splashscreen.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ]
  }
}

There were some updates in the project when I issued npm install again. Then I issued:

expo start

This error came:

(node:2044) UnhandledPromiseRejectionWarning: Error: Cannot find module 'D:\Projects\ReactNativeProjects\AwesomeProject\node_modules\expo\tools\LogReporter'

Why am I getting this error, and how can I fix it?

Abhinav Saxena
  • 1,990
  • 2
  • 24
  • 55
Sadhu
  • 850
  • 2
  • 9
  • 18
  • 5
    You don't provide enough information to let people help you. – nyr1o Mar 07 '18 at 12:00
  • 1
    Can you make sure that the `expo` package is installed in your project? You can remove the `node_modules` folder and then run `npm install` or `yarn` again in your project folder. – fson Mar 07 '18 at 12:57
  • Sadhu I still have this problem, did you solve it? – Mizlul Apr 11 '18 at 14:40
  • @Mizlul If you have the same problem, could you add a comment with a [MCVE](https://stackoverflow.com/help/mcve)? Someone with mod edit privileges can edit it into the question later. As Nyri0 commented, this question as it stands doesn't have enough information. – Michael Cheng Apr 12 '18 at 14:31
  • @Mizlul, please provide a git repo which can be used to reproduce and fix the error – Tarun Lalwani Apr 12 '18 at 15:36
  • Can you post your Package.json file ? – Tarek Apr 18 '18 at 09:24
  • Is expo in the package.json under `dependencies` or `devDependencies` ? – Bastien Robert Apr 18 '18 at 10:09
  • @Mizlul Sorry for late reply... Yes I Solved this. I had some problem with my npm install. – Sadhu Apr 18 '18 at 11:05

5 Answers5

10

check your package.json if it contains all needed dependencies and run npm install in the home directory of the project

if a package is missing you can add it with

npm install <package_name> --save

if you are using yarn run:

yarn add expo
warch
  • 2,387
  • 2
  • 26
  • 43
9

I did:

yarn add expo

and it worked for me =)

mzalazar
  • 6,206
  • 3
  • 34
  • 31
6

See docs:

introducing-button-yarn-and-a-public-roadmap

and

npm-vs-yarn-in-react-native

These documents say that since the project configured using Yarn, you have to follow Yarn way. [Note: There is a file yarn.lock inside the root directory of the project, you have posted]

Therefore such projects are dealt by following the instructions in the documentation.

Please see How do I create a React Native project using Yarn? to actually create a react-native project using Yarn.

And please be sure to remove node_modules folder and issue command npm install before adding react native CLI using yarn. You have to remove package-lock.json from your project root. This will be to prevent mixing different package managers : npm and yarn.

Instead, it will be a good idea not to use npm, and in order to generate node_modules, just issue command:

yarn

Last link recommends to install every package you need using yarn, and not to use any other package manager:

yarn global add react-native-cli

to add react-native:

yarn add react-native

to add missing packages:

yarn add react-base --save

and to install expo using yarn:

yarn add expo

install expo-cli

yarn add expo-cli

It is possible that you can do without Expo. Just focus on react-native and yarn.

Generate android and ios folders:

react-native eject

Start yarn:

yarn start

run build of your choice, and make sure the SDKs are installed.

react-native run-android

Please also see: Uncaught TypeError: Cannot read property 'forEach' of undefined, on a KitchenSink demo

Happy Coding :-)

Community
  • 1
  • 1
Abhinav Saxena
  • 1,990
  • 2
  • 24
  • 55
  • thanks a lot, @Abhinav this was the best solution I got so far. I spent my whole day to rectify the error and your solution saved my day. thanks – amit pandya Nov 13 '18 at 14:37
2

Install the Expo modules

npm install --save

i.e.

npm install expo --save

osundblad
  • 2,675
  • 1
  • 29
  • 34
-1

rollback with npm install -g expo-cli@2.4.3

Umair Khan
  • 111
  • 1
  • 4