React-Native:在项目或这些目录中找不到React [英] React-Native: React could not be found within project or in these directories
问题描述
我们已将react native项目升级为带有react(16.9.0)的最新react native版本(v0.61.2),并且在android上运行良好. 当我们尝试在ios思想上运行它时,我们收到消息:
We have upgraded our react native project to the latest react native version (v0.61.2) with react (16.9.0) and it works perfectly fine on android. When we try to run it on ios thought, we get the message:
warning: the transform cache was reset. Loading dependency graph, done. error: bundling failed: Error: Unable to resolve module `React` from `ios/Pods/React/Libraries/react-native/react-native.js`: React could not be found within the project or in these directories: node_modules
If you are sure the module exists, try these steps:
1. Clear watchman watches: watchman watch-del-all
2. Delete node_modules: rm -rf node_modules and run yarn install
3. Reset Metro's cache: yarn start --reset-cache
4. Remove the cache: rm -rf /tmp/metro-*
我们遵循了升级指南,将所有依赖项更新为最新版本,并更新了Pod. 我实际上不知道在哪里或如何开始调试它,因为这似乎来自Pods文件夹.
We have followed the upgrade guide, updated all dependencies to their latest version and updated the pods. I actually don't know where or how to start debugging this, since this seems to be coming from the Pods folder.
这是我们Pods文件夹的内容:
This is the content of our Pods folder:
ls ios/Pods/
Adjust GoogleDataTransport
Crashlytics GoogleDataTransportCCTSupport
DoubleConversion GoogleUtilities
Fabric Headers
Firebase Local Podspecs
FirebaseABTesting Manifest.lock
FirebaseAnalytics Pods.xcodeproj
FirebaseAnalyticsInterop Protobuf
FirebaseCore Pushwoosh
FirebaseCoreDiagnostics PushwooshInboxUI
FirebaseCoreDiagnosticsInterop React
FirebaseDynamicLinks Target Support Files
FirebaseInstanceID boost-for-react-native
FirebaseRemoteConfig glog
Folly nanopb
GoogleAppMeasurement
并且在我们的node_modules文件夹中,我们拥有(还有更多其他软件包):
and in our node_modules folder, we have (with a lot more other packages):
...
react
depd react-deep-force-update
des.js react-devtools-core
destroy react-is
detect-libc react-lifecycles-compat
detect-newline react-native
...
我当然尝试了所有步骤,例如清除缓存,重置缓存,清除DerivedData,清理并构建... 我不知道从哪里开始寻找.
I have, of course, tried all the steps, like clearing caches, reset-cache, clearing DerivedData, Clean and build, ... I don't know where to start looking.
推荐答案
我通过替换
import Foobar from "screens/foobar";
使用
import Foobar from "./screens/foobar";
请注意路径中的开头./
这篇关于React-Native:在项目或这些目录中找不到React的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!