TCS
TCS

Reputation: 779

Invalid `Podfile` file: cannot load such file

I'm getting to ios folder and use "pod install" command.

And error below

[!] Invalid `Podfile` file: cannot load such file -- /Users/blabla/works/blabla-app/node_modules/react-native/scripts/react_native_pods.

  from /Users/blabla/works/blabla-app/ios/Podfile:2
   -------------------------------------------
   require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
   require_relative '../node_modules/react-native/scripts/react_native_pods'
   
   -------------------------------------------

I removed node_modules folder, I deleted package-lock.json and used "npm install" command. I deleted cocoapods and reinstall.

And nothing worked for me.

My package.json file is below (only packages not all)

"@codler/react-native-keyboard-aware-scroll-view": "^1.0.1",
"axios": "^0.19.0",
"entities": "^2.1.0",
"expo": "^38.0.8",
"expo-cli": "^3.28.5",
"native-base": "github:Healthyco/NativeBase#feature/fix-request-animation",
"native-base-autocomplete": "^1.3.2",
"prop-types": "^15.7.2",
"react": "16.9.0",
"react-native": "0.62.0",
"react-native-camera": "^3.40.0",
"react-native-camera-hooks": "^0.3.1",
"react-native-chart-kit": "^6.7.0",
"react-native-daterange-picker": "^1.4.0",
"react-native-gesture-handler": "^1.3.0",
"react-native-keyboard-aware-scroll-view": "https://github.com/APSL/react-native-keyboard-aware-scroll-view#fb40649a9c84aa23d6a55355e9e0e432795967a6",
"react-native-keyboard-aware-scrollview": "^2.1.0",
"react-native-linear-gradient": "^2.5.6",
"react-native-masked-text": "^1.13.0",
"react-native-modal": "^11.5.6",
"react-native-safe-area-context": "~3.0.7",
"react-native-screens": "^2.7.0",
"react-native-svg": "^12.1.0",
"react-native-swipe-list-view": "^3.2.5",
"react-native-vector-icons": "^7.1.0",
"react-navigation": "^3.11.2",
"react-redux": "^7.2.0",
"redux": "^4.0.1",
"redux-persist": "^5.10.0",
"redux-saga": "^1.0.2",
"reduxsauce": "^1.0.1",
"victory-native": "^35.3.1"

my podfile: I remembered that, I downgraded from react 63.2 to 62.0

require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/react-native/scripts/react_native_pods'

platform :ios, '10.0'

target 'blabla' do
  config = use_native_modules!
  use_react_native!(:path => config["reactNativePath"])

  pod 'RNSVG', :path => '../node_modules/react-native-svg'

  pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'

  target 'blablaTests' 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 'blabla-tvOS' do
  # Pods for [YourProjectName]-tvOS

  target 'blabla-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

Upvotes: 10

Views: 21904

Answers (5)

mayank kaul
mayank kaul

Reputation: 86

None of the mentioned solutions worked for me. I was using VsCode with Auto Attach: Always configuration. Disabled it and ran pod install. Worked well!

Upvotes: 3

DutchFrank
DutchFrank

Reputation: 23

I resolved this by terminating all running node.js instances and running pod install again.

Upgrading react native

I ran into this problem when upgrading from react-native 0.66.5 to 0.73.1 following the steps in the Upgrade-guide.

Part of the upgrade is modifying the node_modules path/reference in the PodFile. After modification the error occurred when a ran pod install.

Stopping all instances of node resolved the issue.

Upvotes: 0

CL2023
CL2023

Reputation: 1

I encountered this same issue while trying to go through React Native's Setting up the development environment guide and tried the following to no avail:

What finally fixed it was following this advice to disable Auto Attach on VSCode.

Upvotes: 0

Tum
Tum

Reputation: 7575

What worked for me whas deleting the ios directory and then running the build command again, i.e.:

rm -rf ios
eas build -p ios

(or whatever build command you are using)

Upvotes: -1

Adonis Gaitatzis
Adonis Gaitatzis

Reputation: 3729

You are likely missing the react-native npm module.

You should include it in your packages.json to reduce the likelihood of encountering this error in the future, by using this command.

$ npm install --save react-native

Upvotes: 4

Related Questions