Expo:找不到模块LogReporter [英] Expo : cannot find a module LogReporter
问题描述
我已经创建了一个React Native项目,并且试图在Expo XDE中打开该项目.它将引发以下错误:
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
首先,我通过克隆KitchenSink项目创建了一个React Native项目. 链接:
Firstly I created a React Native project by cloning a KitchenSink Project. Link:
当我通过在项目根目录内发出一系列命令来启动项目时:
When I started the project by issuing series of commands inside the project root directory:
npm install
然后是expo start
我发现app.json也不合适,如下所示:
I saw that the app.json was also not proper, which was the following:
{
"name": "NativebaseKitchenSink",
"displayName": "NativebaseKitchenSink"
}
发布expo start
后,react-native报告说在当前目录中找不到app.json
.
After issuing expo start
react-native reported that the app.json
is not to be found in the current directory.
[17:05:08]从以下位置开始项目 D:\ Projects \ ReactNativeProjects \ AwesomeProject [17:05:10]错误: 缺少app.json.请参见 https://docs.expo.io/ [17:05:10]无法启动 项目.请更正错误,然后重新启动项目. [17:05:10] 错误:无法启动项目.请修正错误,然后重新启动 项目. 在C:\ xdl@51.4.0 \ src \ Project.js:1565:11 在Generator.next() 在步骤(C:\ Users \ hp \ AppData \ Roaming \ npm \ node_modules \ expo-cli \ node_modules \ xdl \ build \ Project.js:2033:191) 在C:\ Users \ hp \ AppData \ Roaming \ npm \ node_modules \ expo-cli \ node_modules \ xdl \ build \ Project.js:2033:361 在process._tickCallback(internal/process/next_tick.js:68:7)
[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)
我将app.json更改为:
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": [
"**/*"
]
}
}
当我再次发布npm install
时,项目中有一些更新.然后我发出:
There were some updates in the project when I issued npm install
again. Then I issued:
expo start
出现此错误:
(节点:2044)UnhandledPromiseRejection警告:错误:找不到 模块 'D:\ Projects \ ReactNativeProjects \ AwesomeProject \ node_modules \ expo \ tools \ LogReporter'
(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?
推荐答案
检查您的package.json
是否包含所有必需的依赖项,并在项目的主目录中运行npm install
.
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
这篇关于Expo:找不到模块LogReporter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!