Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure of pod install for the React Native project using Yarn Berry - Yarn 3.x or 4.x. #44411

Closed
elite-mob opened this issue May 4, 2024 · 4 comments

Comments

@elite-mob
Copy link

Description

Simply, I can't install the pod for the React Native project when using Yarn - Berry or any newer version like 3.x or 4.x. Has anyone managed to make this work? Thanks!

Error from installing the pod using npx pod-install command

   #  from /Users/administrator/Desktop/abc/ios/Podfile:2
   #  -------------------------------------------
   #  # Resolve react_native_pods.rb with node to allow for hoisting
   >  require Pod::Executable.execute_command('node', ['-p',
   #    'require.resolve(
   #  -------------------------------------------
  Couldn't install Pods. Updating the Pods project and trying again...
  Command `pod install` failed.
  └─ Cause: Invalid `Podfile` file: [!] /opt/homebrew/bin/node -p require.resolve(
      "react-native/scripts/react_native_pods.rb",
      {paths: [process.argv[1]]},
    ) /Users/administrator/Desktop/abc/ios
  
  node:internal/modules/cjs/loader:1205
    throw err;
    ^
  
  Error: Cannot find module 'react-native/scripts/react_native_pods.rb'
  Require stack:
  - /Users/administrator/Desktop/abc/ios/[eval]
      at Module._resolveFilename (node:internal/modules/cjs/loader:1202:15)
      at Function.resolve (node:internal/modules/helpers:199:19)
      at [eval]:1:9
      at runScriptInThisContext (node:internal/vm:209:10)
      at node:internal/process/execution:118:14
      at [eval]-wrapper:6:24
      at runScript (node:internal/process/execution:101:62)
      at evalScript (node:internal/process/execution:136:3)
      at node:internal/main/eval_string:51:3 {
    code: 'MODULE_NOT_FOUND',
    requireStack: [ '/Users/administrator/Desktop/abc/ios/[eval]' ]
  }
  
  Node.js v22.0.0

Here is my project package.json file

{
  "name": "abc",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "react": "18.2.0",
    "react-native": "0.74.1"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/babel-preset": "0.74.83",
    "@react-native/eslint-config": "0.74.83",
    "@react-native/metro-config": "0.74.83",
    "@react-native/typescript-config": "0.74.83",
    "@types/react": "^18.2.6",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.6.3",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "18.2.0",
    "typescript": "5.0.4"
  },
  "engines": {
    "node": ">=18"
  }
}

Steps to reproduce

This issue can be reproduced by following these steps:

  1. Set Yarn version to Berry: yarn set version berry
  2. Initialize a new React Native project: npx react-native init abc

You will encounter failures when installing the pod files, even for existing projects. I'm using React Native versions 0.74.0 and 0.74.1.

React Native Version

0.74.1

Affected Platforms

Runtime - iOS

Output of npx react-native info

info Fetching system and libraries information...
System:
  OS: macOS 14.4.1
  CPU: (8) arm64 Apple M1
  Memory: 1.85 GB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.0.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 3.6.4
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.5.1
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2024.04.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.3 AI-233.14808.21.2331.11709847
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java: Not Found
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native: Not Found
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

#  from /Users/administrator/Desktop/abc/ios/Podfile:2
 #  -------------------------------------------
 #  # Resolve react_native_pods.rb with node to allow for hoisting
 >  require Pod::Executable.execute_command('node', ['-p',
 #    'require.resolve(
 #  -------------------------------------------
Couldn't install Pods. Updating the Pods project and trying again...
Command `pod install` failed.
└─ Cause: Invalid `Podfile` file: [!] /opt/homebrew/bin/node -p require.resolve(
    "react-native/scripts/react_native_pods.rb",
    {paths: [process.argv[1]]},
  ) /Users/administrator/Desktop/abc/ios

node:internal/modules/cjs/loader:1205
  throw err;
  ^

Error: Cannot find module 'react-native/scripts/react_native_pods.rb'
Require stack:
- /Users/administrator/Desktop/abc/ios/[eval]
    at Module._resolveFilename (node:internal/modules/cjs/loader:1202:15)
    at Function.resolve (node:internal/modules/helpers:199:19)
    at [eval]:1:9
    at runScriptInThisContext (node:internal/vm:209:10)
    at node:internal/process/execution:118:14
    at [eval]-wrapper:6:24
    at runScript (node:internal/process/execution:101:62)
    at evalScript (node:internal/process/execution:136:3)
    at node:internal/main/eval_string:51:3 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/Users/administrator/Desktop/abc/ios/[eval]' ]
}

Node.js v22.0.0

Reproducer

https://github.com/elite-mob/Reproducer_React_Native

Screenshots and Videos

Screenshot 2024-05-04 at 7 56 03 AM

@pnthach95
Copy link

You have pod 1.15.2. Read Gemfile, it requires to use 1.13 or 1.14. Reinstall pod and try again

@marelix2
Copy link

marelix2 commented May 6, 2024

adding nodeLinker: node-modules to .yarnrc.yml worked for me

nodeLinker: node-modules
 
yarnPath: .yarn/releases/yarn-3.6.4.cjs

@elite-mob
Copy link
Author

Thanks! It's now resolved - @marelix2

@StefanWallin
Copy link

Had this same problem after new project, pod install failed as part of init script.

Solution:

cd project
npm i
npx pod-install

I tried only running npx pod-install, but needed the npm-packages first of course which somehow was not installed, but no errors. Noticed I was missing a package-lock.json-file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants