React-native: Unable to resolve Module 'React' after upgrading to 0.61.4

Created on 14 Nov 2019  路  8Comments  路  Source: facebook/react-native

I am getting this issue after upgrading to 0.61.4 in ios
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

I tried npm start -- -- reset-cache, clearing derived data. clean project etc.
tried replacing
var ReactNative = Object.assign(Object.create(require('React')), {
with
var ReactNative = Object.assign(Object.create(require('react')), {
in /ios/Pods/React/Libraries/react-native/react-native.js

But the issue exists in the file react-native.js

image

React Native version:
System:
OS: macOS Mojave 10.14.4
CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 172.62 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.15.0 - /usr/local/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
IDEs:
Xcode: 11.2/11B52 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: ^0.61.4 => 0.61.4
npmGlobalPackages:
react-native-cli: 2.0.1

Steps To Reproduce

  1. Run project from Xcode
  2. The app starts with this red screen with error
Bug 馃摝Bundler

Most helpful comment

@krishnadas89
I've got the same error.

Steps I've done:

  1. rm -rf ios/Pods
  2. rm -rf node_modules
  3. Changed pod 'React', :path => '../node_modules/react-native' to pod 'React', :path => '../node_modules/react-native/' in Podfile.
  4. npm cache clean --force
  5. npm install
  6. npm install redux
  7. cd ios && pod install
  8. Bulit project in Xcode
  9. Run app in Xcode

And it worked. 馃憤

All 8 comments

Likely a caching issue, most probably watchman. Please run watchman watch-del-all and then yarn start --reset-cache again.

I dont even have watchman installed.
So watchman watch-del-all gives command not found error in terminal

Likely a caching issue, most probably watchman. Please run watchman watch-del-all and then yarn start --reset-cache again.

Oh, I see it now. Metro tries to resolve ios/Pods/React/Libraries/react-native/react-native.js but there shouldn't be React pod in your pods, it should be taken from node_modules.

Remove ios/Pods and run pod install again. Also make sure your Podfile is valid and looks like this one: https://github.com/facebook/react-native/blob/0.61-stable/template/ios/Podfile

Oh Thanks. The error screen is gone. But now the app is stuck with a white screen. But no breakpoints in Xcode . Just white screen.

Various things could happen. Turn off debugger, turn it on again. Uninstall the app and install again on the device/emulator. Should work then :) If not, open Debugger and set "pause on exceptions" to see if some JS fails to run. Anyway, not a RN issue.

pod install

this way works for me

Oh, I see it now. Metro tries to resolve ios/Pods/React/Libraries/react-native/react-native.js but there shouldn't be React pod in your pods, it should be taken from node_modules.

Remove ios/Pods and run pod install again. Also make sure your Podfile is valid and looks like this one: https://github.com/facebook/react-native/blob/0.61-stable/template/ios/Podfile

as per the reference link you provided ( https://github.com/facebook/react-native/blob/0.61-stable/template/ios/Podfile), there is React pod in Podfile. Even if I remove that from Podfile, I still get the same error. I upgraded to react-native 0.62.2 and react 16.13.1

@krishnadas89
I've got the same error.

Steps I've done:

  1. rm -rf ios/Pods
  2. rm -rf node_modules
  3. Changed pod 'React', :path => '../node_modules/react-native' to pod 'React', :path => '../node_modules/react-native/' in Podfile.
  4. npm cache clean --force
  5. npm install
  6. npm install redux
  7. cd ios && pod install
  8. Bulit project in Xcode
  9. Run app in Xcode

And it worked. 馃憤

Was this page helpful?
0 / 5 - 0 ratings