react-native – Expo:找不到模块LogReporter

前端之家收集整理的这篇文章主要介绍了react-native – Expo:找不到模块LogReporter前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我创建了一个React Native Project,我试图在Expo XDE中打开该项目.它会抛出以下错误

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

首先,我通过克隆KitchenSink项目创建了一个React Native项目.
链接

NativeBase-KitchenSink

当我通过在项目根目录中发出一系列命令来启动项目时:

npm install然后expo start

我看到app.json也不合适,具体如下:

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

发布expo start后,react-native报告在当前目录中找不到app.json.

[17:05:08] Starting project at
D:\Projects\ReactNativeProjects\AwesomeProject [17:05:10] Error:
Missing app.json. See 07001 [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)

我将app.json更改为:

{
  "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": [
      "**/*"
    ]
  }
}

当我再次发出npm install时,项目中有一些更新.然后我发出:

expo start

出现此错误

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

为什么我会收到此错误,我该如何解决

检查你的package.json,如果它包含所有需要的依赖项,并在项目的主目录中运行npm install

如果缺少包,您可以添加

npm install <package_name> --save

如果你正在使用纱线运行:

yarn add expo

猜你在找的React相关文章