I’ve created a new React Native project using the recommended template, but when I try to install pods for this new project, I get the following error:
[!] Invalid `Podfile` file: cannot load such file -- /Users/..../AwesomeProject/node_modules/react-native/scripts/react_native_pods.rb
My Podfile:
# 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__]).strip
platform :ios, min_ios_version_supported
prepare_react_native_project!
linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
use_frameworks! :linkage => linkage.to_sym
end
target 'AwesomeProject' do
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
target 'AwesomeProjectTests' do
inherit! :complete
# Pods for testing
end
post_install do |installer|
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
react_native_post_install(
installer,
config[:reactNativePath],
:mac_catalyst_enabled => false,
# :ccache_enabled => true
)
end
end
node -v: 21.6.1
pod version: 1.15.2
I checked that the react_native_pods.rb is present in the node_modules … react-native/scripts/react_native_pods.rb
Tried to use both yarn and default npm, both gives the error above (tried cleaning cache).
npm audit fix also didn’t` helped.
Tried reinstalling pods via brew reinstall cocoapods but got the same error when used pod install in ios folder of React Native project.
Installing pods via bundle exec pod install doesn’t help either.
Strangest thing is that I was able to install pods for all my projects 2 weeks ago. But when I am doing it now, without changing anything in my OS system, I cannot install pods even in the new created project by npx react-native@latest init AwesomeProject.
Aldra1n is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.