upgrade-support icon indicating copy to clipboard operation
upgrade-support copied to clipboard

Cannot run pod install in hybrid iOS project on RN 63

Open jemise111 opened this issue 4 years ago • 0 comments

Environment

System:
    OS: macOS 11.0.1
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Memory: 189.80 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 13.7.0 - /var/folders/y7/pd576yls2g5f9mldf1th5jt40000gn/T/yarn--1610123832461-0.48752617436542023/node
    Yarn: 1.22.5 - /var/folders/y7/pd576yls2g5f9mldf1th5jt40000gn/T/yarn--1610123832461-0.48752617436542023/yarn
    npm: Not Found
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.0 - /Users/jemise111/.rvm/gems/ruby-2.7.0/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6626763
    Xcode: 12.3/12C33 - /usr/bin/xcodebuild
  Languages:
    Java: javac 15 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1
    react-native: 0.63.4 => 0.63.4
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
✨  Done in 7.06s

Things I’ve done to figure out my issue

Upgrading version

Upgrading from RN 62.2 to RN 63.4

Description

After upgrading from RN 62.2 to RN 63.4 when I run pod install I get the following error message:

[!] Invalid `Podfile` file: [!] /Users/jemise111/.nvm/versions/node/v13.7.0/bin/node -e try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}

internal/modules/cjs/loader.js:983
  throw err;
  ^

Error: Cannot find module 'react-native/cli'
Require stack:
- /Users/jemise111/sources/Delivery-iOS-Native/[eval]
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
    at Function.Module._load (internal/modules/cjs/loader.js:862:27)
    at Module.require (internal/modules/cjs/loader.js:1040:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at [eval]:1:87
    at Script.runInThisContext (vm.js:120:20)
    at Object.runInThisContext (vm.js:311:38)
    at Object.<anonymous> ([eval]-wrapper:10:26)
    at Module._compile (internal/modules/cjs/loader.js:1151:30)
    at evalScript (internal/process/execution.js:94:25) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/Users/jemise111/sources/Delivery-iOS-Native/[eval]' ]
}
.

 #  from /Users/jemise111/sources/Delivery-iOS-Native/Podfile:63
 #  -------------------------------------------
 #  target 'Delivery' do
 >  	config = use_native_modules!
 #  	use_react_native!(:path => config["reactNativePath"])
 #  -------------------------------------------

I suspect this is due to my project's directory structure. We integrated RN into an existing iOS application using cocoapods. So our project looks like:

Project
├── Project.xcworkspace/
├── Podfile
├── pods/
├── ...
├── ReactComponents/
    ├── index.js
    └── node_modules/
        └── react-native/

Therefore at the root level the cli.bin cannot be found. I could manually change the require statement to require('./ReactComponents/node_modules/@react-native-community/cli').bin but I suspect that would come with it's own host of issues.

How can I run pod install given the changes made to the Podfile in RN 63? FWIW We've never had an issue with RN dependencies using cocoapods before

jemise111 avatar Jan 11 '21 22:01 jemise111