facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.23k stars 24.34k forks source link

Cannot run pod install in hybrid iOS project on RN 63 #30705

Closed jemise111 closed 3 years ago

jemise111 commented 3 years ago

Please provide all the information requested. Issues that do not follow this format are likely to stall.

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

React Native version:

Run react-native info in your terminal and copy the results here:

info Fetching system and libraries information...
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

Steps To Reproduce

Please see description

Expected Results

Expect to be able to run pod install without issue

Snack, code example, screenshot, or link to a repository:

Please see description

safaiyeh commented 3 years ago

Hi @jemise111 thank you for the issue. Apologies you are having issues.

I did a quick check and it seems there may be a resolution here: https://github.com/react-native-community/cli/issues/995.

For issues pertaining to upgrades please see https://github.com/react-native-community/upgrade-support/issues to file upgrade issues.

github-actions[bot] commented 3 years ago

Do you need help upgrading to a newer React Native version? Visit the Upgrade Support repository or use the upgrade helper to see the changes that need to be made to upgrade your app.

jemise111 commented 3 years ago

Hi @safaiyeh thanks for the advice but that resolution is for an Android project, this pertains to iOS only.

I'll post this on the upgrade support repo and see if I have luck there