'React Native - pod install issue "cannot load such file.......node_modules/react-native/scripts/react_native_pods"

when I have a react native project....and when I run pod install it gives me the following error

Invalid `Podfile` file: cannot load such file -- /myPath/node_modules/react-native/scripts/react_native_pods

Here is my podfile

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '10.0'

target 'xs' do
  config = use_native_modules!

  use_react_native!(:path => config["reactNativePath"])

  target 'xsTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  use_flipper!
  post_install do |installer|
    flipper_post_install(installer)
  end
end

target 'xs-tvOS' do
  # Pods for xs-tvOS

  target 'xs-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

Ive checked and there is no file called react_native_pods in location myPath/node_modules/react-native/scripts/. Im wondering if its something to do with npm install is not generating correct files.....however I upgraded node to most recent version and then ran npm install



Solution 1:[1]

I ran npm audit fix and it added react_native_pods file and pod install then worked

Solution 2:[2]

Run npm audit fix ==> cd ios ==> pod install

Solution 3:[3]

If npm audit fix is not working for you then try below solution.

- sudo gem install cocoapods
- npm i
- cd ios
- pod install

Solution 4:[4]

It can also be that you just forgot to run yarn / npm before running pod install.

Solution 5:[5]

I have meet the same error, solved by upgrade the version of React Native from 0.62 to 0.63, it works for me Because of the file react_native_pods does't exists in the folder scripts when the version is 0.62, It appears when I upgraded the version of RN to 0.63, after npm install , It works when pod install, hope it would help other who encounter the same error

Solution 6:[6]

in order to fix this: what i did is:

  1. react-native upgrade: It mainly upgrades react-native version, which will also upgrade some of your ios files such as Podfile amongst other things.

Try if this works for you or not. You can also create a latest react native project and compare your files/directories using "Beyond compare", also you need to rename some lines in your files.

Also read the comments in files for better understanding.

Solution 7:[7]

In my case Ive deleted yarn.lock, podfile.lock and it worked fine after yarn and pod install again

Solution 8:[8]

I just did npm install before running pod install and it solved for me.

Solution 9:[9]

This wroked for me:

cd ios
sudo arch -x86_64 gem install ffi
arch -x86_64 pod install

Via this link.

Solution 10:[10]

verify that you have a node_modules folder, I was missing that

Solution 11:[11]

Go and add react-native.pods.rb file inside of Node_Module->React-Native->Scripts->(add here)