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_podsHere 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
endIve 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
17 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
3If npm audit fix is not working for you then try below solution.
- sudo gem install cocoapods
- npm i
- cd ios
- pod install 1 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.
Make sure you've installed your npm dependencies.
Run following command and then install pods.
- To install npm packages:
yarn install
- And then, remove old pod cache:
cd ios && pod deintegrate && rm -rf Podfile.lock
- To update pods and start ios:
1pod install --repo-update && cd .. && react-native run-ios
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:
- 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 installVia this link.
just install,
@react-native-community/cli-platform-iosin 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.
In my case, I installed cocoapods from brew and gem
Based on the latest react-native documents, you will need to install it from gem
Do the following steps:
sudo brew uninstall cocoapodsto remove cocoapods install viabrewsudo gem uninstall cocoapodsto remove cocoapods installed viagem
Finally
sudo gem install cocoapodsto install the latest version viagem
Yarn cd ios pod install
Works for me
1This happened to me on mac after installing MacOs 14.0 Sonoma. I'm not entirely sure what the issue was. The files that were being relatively required by either
require_relative '../node_modules/react-native/scripts/react_native_pods'
or
2.
Resolve react_native_pods.rb with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p', 'require.resolve( "react-native/scripts/react_native_pods.rb", {paths: [process.argv[1]]}, )', __dir__]).stripExisted and i could expect them but cocoapods could either not make sense of them or not locate them.
In the end i had to completely remove rvm with rvm implode and rvm uninstall. Reinstall it cleanly and use a Ruby version compatible with the one listed in my Gemfile ruby ">= 2.6.10"
I chose to use 2.7.8 as it's the highest 2.x.y version, at present.
After that i had to reinstall the following gems
- activeSupport 7.0.8
- bundler
- cocoapods
I went to the root of the react-native project and did bundle install
Then went into ios and ran pod install.
This was all on a freshly created react-native projectnpx react-native@latest init AwesomeProject
"react": "18.2.0", "react-native": "0.72.5",And everything seemed to be working fine. My theory is that after updating MacOs. It replaced some of my rvm path binaries with ones from the default installation breaking things. Or, my ruby version was just wrong/confused on 3.x and i needed a fresh start on the compatible 2.x.y version.
verify that you have a node_modules folder, I was missing that
0Go and add react-native.pods.rb file inside of Node_Module->React-Native->Scripts->(add here)