cli icon indicating copy to clipboard operation
cli copied to clipboard

Cannot run pod install in hybrid iOS project on RN 63

Open jemise111 opened this issue 5 years ago • 2 comments

(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

jemise111 avatar Jan 08 '21 16:01 jemise111

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

stickor avatar May 13 '22 08:05 stickor

@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

jemise111 avatar May 13 '22 14:05 jemise111

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.

github-actions[bot] avatar Nov 26 '22 03:11 github-actions[bot]