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

Viewed 42770

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

14 Answers

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

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

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

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

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

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

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

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

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.

This wroked for me:

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

Via this link.

Yarn cd ios pod install

Works for me

just install,

@react-native-community/cli-platform-ios

in package.json

then yarn install in your root and cd ios and also arch -x86_64 pod install

I had this error in 2022 and this was the most relevant search result and didn't fix it.. so in case anyone else out there is running into this, I fought this for days and finally fixed it by:

Creating a brand new directory by: expo init new-project and then copy over your .js files, screens, and assets etc. Do this by hand, don't copy any of your lock files or node-modules or anything else. Just the files that you created/touched yourself. Then expo start. Load the project on your mobile / simulator and when it fails with a module requirement missing add it individually. Repeat this start-error-add until the build succeeds. This was the only way I found to get it working.

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

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

Related