18

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-*

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.

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

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
...

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.

1
  • 3
    Having exactly the same here. Commented Oct 21, 2019 at 19:17

6 Answers 6

10

I fixed it by replacing

import Foobar from "screens/foobar";

with

import Foobar from "./screens/foobar";

note the beginning ./ in the path

Sign up to request clarification or add additional context in comments.

Comments

3

Try to delete both Pod folder and Podfile.lock, under ios directory. Then run pod install again.

That worked for me.

Comments

1

I know this isn't an optimal solution, however I spent over a week on this going down the rabbit hole to no avail. In the end I generated a new RN project, copied over my app folder and reinstalled about 20 packages which I use, and then copied my old App.js, index.js, AndroidManifest, Appdelegate.m, Info.plist, build.gradle x 2, icons and XIB, and some misc installation instructions for modules, i.e. FBSDK and Firebase. It now all works fine. It seems that something in the manual process of updating all those files to get from <0.60 to >0.60 causes an issue for some. Note that this recreation took about 8 hours.

Comments

0

last week, I also met the problem, it caused by the react path had changed.

open your ios folder Podfile, edit the react path. it had moved into react-native

 pod 'React', :path => '../node_modules/react-native/'
 pod 'React-Core', :path => '../node_modules/react-native/'

then cd ios folder and run pod install in the terminal

expect above, if you had met other upgrade problems, you can go to this site compare the related files

6 Comments

I have changed as per above but it shows error as Fetching podspec for BVLinearGradient from ../node_modules/react-native/react-native-linear-gradient [!] No podspec found for BVLinearGradient in ../node_modules/react-native/react-native-linear-gradient
@sejn, it is the same, react-native-linear-gradient don not exist in Podfile. according to the API(npmjs.com/package/react-native-linear-gradient); add this pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
[!] Unable to find a specification for React-Core depended upon by rn-fetch-blob [!] Automatically assigning platform ios with version 8.0 on target App because no platform was specified. Please specify a platform for this target in your Podfile. See https://guides.cocoapods.org/syntax/podfile.html#platform.
@sejn modify rn-fetch-blob.podspec: s.dependency 'React-Core' .you can also run this grep -rl "s.dependency 'React/Core'" node_modules/ | xargs sed -i '' 's=React/Core=React-Core=g' in termail
Shall I need to change in podfile as s.dependency 'React-Core'
|
0

I don't know if you tried to update your pods or not but you could try to do following inside your ios/ folder:

pod repo update && pod install

It might help.

Comments

-1

Please check react dependency is there or not in package.json . if not Add react dependency in project using yarn or npm and try it

npm install react / yarn add react

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.