react-native-community / cli

The React Native Community CLI - command line tools to help you build RN apps
MIT License
2.34k stars 899 forks source link

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

Closed jemise111 closed 1 year ago

jemise111 commented 3 years ago

(I've cross posted this here: https://github.com/facebook/react-native/issues/30705, as I'm not sure if the bug is in RN or RN CLI)

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

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

stickor commented 2 years ago

@jemise111 I have the same problem Can you tell me how you finally solved it?

jemise111 commented 2 years ago

@stickor I joined a different company 😂

IIRC we either were never able to upgrade or we found ran a patch to change some of the import statements. Sorry I can't be of more help

github-actions[bot] commented 1 year ago

There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.