cli: Error: Cannot find module 'react-native/scripts/react_native_pods.rb'
Environment
System:
OS: macOS 14.1.1
CPU: (12) arm64 Apple M2 Max
Memory: 1.21 GB / 32.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 18.17.1
path: /usr/local/bin/node
Yarn:
version: 3.6.2
path: /usr/local/bin/yarn
npm:
version: 9.6.7
path: /usr/local/bin/npm
Watchman:
version: 2023.11.20.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.14.3
path: /Users/user/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.0
- iOS 17.0
- macOS 14.0
- tvOS 17.0
- watchOS 10.0
Android SDK: Not Found
IDEs:
Android Studio: 2022.3 AI-223.8836.35.2231.11005911
Xcode:
version: 15.0.1/15A507
path: /usr/bin/xcodebuild
Languages:
Java:
version: 11.0.21
path: /usr/bin/javac
Ruby:
version: 3.2.2
path: /Users/user/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.7
wanted: 0.72.7
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: true
Description
when running npx react-native@latest init AwesomeProject,
✖ Installing CocoaPods dependencies (this may take a few minutes)
error
[!] Invalid `Podfile` file: [!] /usr/local/bin/node -p require.resolve(
"react-native/scripts/react_native_pods.rb",
{paths: [process.argv[1]]},
) /Users/user/Documents/sources/AwesomeProject/ios
node:internal/modules/cjs/loader:1080
throw err;
^
Error: Cannot find module 'react-native/scripts/react_native_pods.rb'
Require stack:
- /Users/user/Documents/sources/AwesomeProject/ios/[eval]
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Function.resolve (node:internal/modules/cjs/helpers:127:19)
at [eval]:1:9
at Script.runInThisContext (node:vm:123:12)
at Object.runInThisContext (node:vm:299:38)
at node:internal/process/execution:79:19
at [eval]-wrapper:6:22
at evalScript (node:internal/process/execution:78:60)
at node:internal/main/eval_string:28:3 {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/Users/user/Documents/sources/AwesomeProject/ios/[eval]' ]
}
Node.js v18.17.1
.
# from /Users/user/Documents/sources/AwesomeProject/ios/Podfile:2
# -------------------------------------------
# # Resolve react_native_pods.rb with node to allow for hoisting
> require Pod::Executable.execute_command('node', ['-p',
# 'require.resolve(
# -------------------------------------------
✖ Installing CocoaPods dependencies (this may take a few minutes)
error Looks like your iOS environment is not properly set. Please go to https://reactnative.dev/docs/environment-setup?os=macos&platform=android and follow the React Native CLI QuickStart guide for macOS and iOS.
info Run CLI with --verbose flag for more details.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 16
This problem occurs when we install bundle and then go for pod without installing node_modules… so first install node_modules so that when native files fetch react native files it must be available in node_modules…
DONOT try to run on debugger. Stop the debugger try npm i -f and then cd ios then pod install.
@orange4glace You’re using Yarn v3 with PnP if you’re inside monorepo, please use
nodeLinker: node-modulesinside.yarnrc.ymlconfig file. Or if you’re not in monorepo please downgrade Yarn to v1, or if you don’t want - you can use latest RC which already contains a fix for this:I was getting this same error. I was able to resolve with the following:
From the project root
npm installnvm use 18cd iosbundle exec pod installHopefully this helps someone else.
hey @sujitmohanty, you should do it inside project’s directory. or if you want to keep Yarn v3, you just need to provide
.yarnrc.ymlwithnodeLinker: node-modules.hey @exequiel-criss, please make sure that you’re
node_modulesare installed correctly and also that you’re usingnodeLinker: node-moduleswith higher Yarn versions.@raushanxstan awesome! thanks for guide me
@szymonrybczak
I’m getting a similar error, please take a look into it. If it’s irrelevant, please let me know to create a new issue.
I’m using NPM instead of Yarn in my project. should we necessarily use Yarn to make
pod installwork? I should mention that I don’t have macOS, so I installed Cocoapods v1.15.2 (the latest version as I’m writing this comment) on my Windows 10 and I’m trying to install dependencies and make thepod.lockfile for the project.I already have
node_modulesinstalled in my project and this is my Podfile’s content from RN v0.74.3:when executing
pod installin the ios directory it gives me this error:Ahh I see. Thank you so much for responding!
Thank you so much! I was able to solve it, I had to create a file in the root of the project with the name
.yarnrcand inside the file--install.nodeLinker=node-modulesThen I deleted the node_modules folder, I did a pod install and a yarn install and it was solved.