pod install fails with 'Invalid Podfile file: no implicit conversion of nil into String'
[!] Invalid `Podfile` file: no implicit conversion of nil into String.Short answer
A React Native Podfile starts by running node to find react_native_pods.rb. If node is not on the PATH CocoaPods sees, or react-native is not installed under node_modules, the lookup fails and the Podfile stops. Check the lookup by hand, install the JavaScript packages, and make node visible.
Fix it fast
1Find out which cause you have
Run the same lookup the Podfile runs, from the ios folder. If it prints a path, the Podfile can start; if it prints an error or nothing, you have found the cause.
cd ios node -p 'require.resolve("react-native/scripts/react_native_pods.rb", {paths: [process.cwd()]})'2Match what you see, then jump to its fix
What does the error look like?
[!] Invalid `Podfile` file: no implicit conversion of nil into String.
Cause 1 of 2
The JavaScript packages are not installed
1Check
The Podfile resolves react-native through Node's module lookup, starting from the ios folder. Without node_modules, or after a fresh clone, there is nothing to find.
ls node_modules/react-native/scripts/react_native_pods.rb2Fix
Install the packages from the project root, then run the pod step again from the ios folder.
npm install
cd ios && bundle exec pod install3Verify
pod install gets past the Podfile and starts resolving pods.
cd ios && bundle exec pod installConfirmed by raw.githubusercontent.com
Cause 2 of 2
node is not on the PATH of the shell running pod install
1Check
The Podfile starts node itself, so CocoaPods needs node on its PATH. The setup guide installs node with Homebrew and asks for Node 22.11.0 or newer.
which node
node --version2Fix
Install or link Node.js (the guide uses Homebrew), open a new terminal so the PATH is updated, and run the command from that shell. Xcode builds read the node path from .xcode.env.
brew install node
node --version3Verify
The lookup from the first step prints a path.
cd ios
node -p 'require.resolve("react-native/scripts/react_native_pods.rb", {paths: [process.cwd()]})'Confirmed by reactnative.dev
How do I stop it coming back?
- After every clone or branch switch, run your package install first and the pod step second.
- Run pod install from the ios folder of the project, using bundle exec once you have run bundle install.
- Keep one Node.js installation on the machine, so every terminal and Xcode resolves the same node.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Mobile apps
Xcode cannot find node when building a React Native iOS app
[Warning] You need to configure your node path in the ".xcode.env" file environment.
Xcode runs the React Native bundle script without your terminal's PATH, so it needs a path to node.
4 causes, each with a fixMobile apps
Xcode release build fails because Metro did not produce main.jsbundle
Your environment is misconfigured as Metro was not able to produce the bundle so your release application won't work!
The Xcode build phase asks Metro for a JavaScript bundle, and the build fails when that bundle was not written.
3 causes, each with a fixMobile apps
Running pod on a React Native project fails with can't find gem cocoapods
can't find gem cocoapods (>= 0.a) with executable pod
The pod command exists, but the Ruby that is running it has no CocoaPods gem.
3 causes, each with a fixMobile apps
Gradle cannot run node in a React Native Android build
Process 'command 'node'' finished with non-zero exit value 1
The React Native Gradle plugin starts node for bundling.
3 causes, each with a fixMobile apps
Axios request works on iOS or in a browser but fails on Android with Network Error
AxiosError: Network Error
A React Native app has no CORS, so on Android a Network Error usually means the request never reached the server.
3 causes, each with a fixMobile apps
Axios returns Network Error in a React Native app on iPhone or the iOS Simulator
error.code is ERR_NETWORK and error.response is undefined
A Network Error means iOS stopped the request before any HTTP answer came back.
3 causes, each with a fix