question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid `Podfile` file: No such file or directory - npx

See original GitHub issue

Report

React Native Version (0.61.5)

React Native version: react-native: 0.61.5 => 0.61.5

System:
    OS: macOS 10.15.2
    CPU: (4) x64 Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz
    Memory: 95.25 MB / 8.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 13.6.0 - /usr/local/bin/node
    npm: 6.13.4 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 29
      Build Tools: 29.0.2
      System Images: android-29 | Google Play Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: 0.61.5 => 0.61.5 
  npmGlobalPackages:
    react-native-git-upgrade: 0.2.7

Steps To Reproduce

What did you do?

  1. Installed the latest version of node
  2. Ran npx react-native init AwesomeProject to create a new application (as per React Native documentation).

What did you expect to happen?

The generation of a fresh React Native project ready to be used.

What happened instead?

When running npx react-native init AwesomeProject, I got this error message:

✔ Downloading template
✔ Copying template
✔ Processing template
⠏ Installing CocoaPods dependencies (this may take a few minutes)
[!] Invalid `Podfile` file: No such file or directory - npx.

 #  from /Users/samyabouseda/Learning/ReactNative/Geolocation/ios/Podfile:42
 #  -------------------------------------------
 #  
 >    use_native_modules!
 #  end
 #  -------------------------------------------

✖ Installing CocoaPods dependencies (this may take a few minutes)
error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Please try again manually: "cd ./Geolocation/ios && pod install".

I then followed the instructions of the error message and ran pod install --verbose in the ios folder of the generated project. pod install seems to fail, here is the error I always get:

[!] Invalid `Podfile` file: No such file or directory - npx.

 #  from /Users/samyabouseda/Learning/ReactNative/Geolocation/ios/Podfile:42
 #  -------------------------------------------
 #  
 >    use_native_modules!
 #  end
 #  -------------------------------------------

/Users/samyabouseda/Applications/CocoaPods.app/Contents/Resources/bundle/lib/ruby/gems/2.2.0/gems/cocoapods-core-1.5.2/lib/cocoapods-core/podfile.rb:299:in `rescue in block in from_ruby'
/Users/samyabouseda/Applications/CocoaPods.app/Contents/Resources/bundle/lib/ruby/gems/2.2.0/gems/cocoapods-core-1.5.2/lib/cocoapods-core/podfile.rb:293:in `block in from_ruby'
/Users/samyabouseda/Applications/CocoaPods.app/Contents/Resources/bundle/lib/ruby/gems/2.2.0/gems/cocoapods-core-1.5.2/lib/cocoapods-core/podfile.rb:50:in `instance_eval'
/Users/samyabouseda/Applications/CocoaPods.app/Contents/Resources/bundle/lib/ruby/gems/2.2.0/gems/cocoapods-core-1.5.2/lib/cocoapods-core/podfile.rb:50:in `initialize'
/Users/samyabouseda/Applications/CocoaPods.app/Contents/Resources/bundle/lib/ruby/gems/2.2.0/gems/cocoapods-core-1.5.2/lib/cocoapods-core/podfile.rb:291:in `new'
/Users/samyabouseda/Applications/CocoaPods.app/Contents/Resources/bundle/lib/ruby/gems/2.2.0/gems/cocoapods-core-1.5.2/lib/cocoapods-core/podfile.rb:291:in `from_ruby'
/Users/samyabouseda/Applications/CocoaPods.app/Contents/Resources/bundle/lib/ruby/gems/2.2.0/gems/cocoapods-core-1.5.2/lib/cocoapods-core/podfile.rb:257:in `from_file'
/Users/samyabouseda/Applications/CocoaPods.app/Contents/Resources/bundle/lib/ruby/gems/2.2.0/gems/cocoapods-1.5.2/lib/cocoapods/config.rb:191:in `podfile'
/Users/samyabouseda/Applications/CocoaPods.app/Contents/Resources/bundle/lib/ruby/gems/2.2.0/gems/cocoapods-1.5.2/lib/cocoapods/command.rb:148:in `verify_podfile_exists!'
/Users/samyabouseda/Applications/CocoaPods.app/Contents/Resources/bundle/lib/ruby/gems/2.2.0/gems/cocoapods-1.5.2/lib/cocoapods/command/install.rb:37:in `run'
/Users/samyabouseda/Applications/CocoaPods.app/Contents/Resources/bundle/lib/ruby/gems/2.2.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/Users/samyabouseda/Applications/CocoaPods.app/Contents/Resources/bundle/lib/ruby/gems/2.2.0/gems/cocoapods-1.5.2/lib/cocoapods/command.rb:52:in `run'
/Users/samyabouseda/Applications/CocoaPods.app/Contents/Resources/bundle/lib/ruby/gems/2.2.0/gems/cocoapods-1.5.2/bin/pod:55:in `<top (required)>'
/Users/samyabouseda/Applications/CocoaPods.app/Contents/Resources/bundle/bin/pod:22:in `load'
/Users/samyabouseda/Applications/CocoaPods.app/Contents/Resources/bundle/bin/pod:22:in `<main>'

Here is what’s inside the ios folder

├── Geolocation
│   ├── AppDelegate.h
│   ├── AppDelegate.m
│   ├── Base.lproj
│   │   └── LaunchScreen.xib
│   ├── Images.xcassets
│   │   ├── AppIcon.appiconset
│   │   │   └── Contents.json
│   │   └── Contents.json
│   ├── Info.plist
│   └── main.m
├── Geolocation-tvOS
│   └── Info.plist
├── Geolocation-tvOSTests
│   └── Info.plist
├── Geolocation.xcodeproj
│   ├── project.pbxproj
│   └── xcshareddata
│       └── xcschemes
│           ├── Geolocation-tvOS.xcscheme
│           └── Geolocation.xcscheme
├── GeolocationTests
│   ├── GeolocationTests.m
│   └── Info.plist
└── Podfile

Here is the Podfile

platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'Geolocation' do
  # Pods for Geolocation
  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  target 'GeolocationTests' do
    inherit! :search_paths
    # Pods for testing
  end

  use_native_modules!
end

target 'Geolocation-tvOS' do
  # Pods for Geolocation-tvOS

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

end

The Podfile is there, the repo is fresh, everything seems up to date and using an older version of React Native works.

Remarks

  • When removing the instruction use_native_modules ! the pod install runs successfully.

Other things I’ve tried

  1. Run the Doctor command: https://facebook.github.io/react-native/blog/
  2. Follow these instructions
  3. Uninstall nodeJS & install it again
  4. Uninstall ruby & install it again
  5. Uninstall yarn & install it again
  6. Uninstall CocoaPods & install it again
  7. Restart the machine
  8. Bang my head on the keybvbeiuqueewrewqwrq qeewqr

Please advise! 🙂

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
davlhdcommented, Jan 28, 2020

Further investigation revealed that its a problem with cocoapods.

I had version 1.5.2. Updating to 1.8.4 solved the issue.

I used sudo gem install cocoapods -n/usr/local/bin from https://stackoverflow.com/questions/39481636/updating-to-latest-version-of-cocoapods

1reaction
samyabousedacommented, Jan 29, 2020

Why can’t I set up a fresh React Native project ?

The command to install the pods fail.

Why does the command to install the pods fail ?

It seems there is an error/issue coming from the “use_native_modules !” in the autogenerated Podfile.

Note: When removing this line, the install runs successfully.

Why is there an error coming from the “use_native_modules !” command ?

The following piece of code is triggering the error in native_modules.rb.

if (!config)
    json = []

    IO.popen("npx --quiet react-native config") do |data|
      while line = data.gets
        json << line
      end
    end

    config = JSON.parse(json.join("\n"))
  end

The method “IO.popen” can’t run the command npx --quiet react-native config because it can’t find npx.

Why npx can’t be found ?

Context

npm

% npm -v
6.13.6
% which npm   
/usr/local/bin/npm

Node

% node -v
v13.7.0
% which node
/usr/local/bin/node

npx

% npx -v
6.13.6
% which npx
/usr/local/bin/npx

I tried outputting the version of each from the native_modules.rb by doing this:

IO.popen("node -v ") do |data|
      while line = data.gets
          puts(line)
      end
    end

But neighter Node, npm nor npx are found.

However, when replacing by the full path (as bellow), it can find Node, npm but still can’t find npx.

IO.popen("/usr/local/bin/npm -v ") do |data|
      while line = data.gets
          puts(line)
      end
    end

The problem is probably coming from two versions of Node, cocoapod (or ruby maybe) clashing. But from there I really don’t know where to go…

Read more comments on GitHub >

github_iconTop Results From Across the Web

5 - Stack Overflow
React Native invalid podfile "No such file or directory - ./node_modules/.bin/react-native." Ask Question. Asked 3 years, 3 months ago. Modified 1 year ...
Read more >
Search - appsloveworld.com
Coding example for the question React Native invalid podfile "No such file or directory - ./node_modules/.bin/react-native."-React Native.
Read more >
Pod install failed: No such file or directory @ rb_sysopen - Builds
pod install works in local. Error. Errno::ENOENT - No such file or directory @ rb_sysopen - /Users/vagrant/git/DatingApp/Pods/ ...
Read more >
How to fix “pod install” error in React Native on Mac M1
sudo gem install cocoapods. to install cocoapods , the standard dependency manager for Swift and Objective-C projects. · npx react-native init AwesomeApp -- ......
Read more >
React Native Ios Invalid Podfile File Undefined - Alvindayu.com
Invalid Podfile file unexpected template EOS. `react-native-camera` returns a data.uri but image cannot be accessed (no such file or directory) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found