无效的“Podfile”文件:无法加载此类文件

TCS*_*TCS 8 react-native

我正在进入 ios 文件夹并使用“pod install”命令。

和下面的错误

[!] 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'
   
   -------------------------------------------
Run Code Online (Sandbox Code Playgroud)

我删除了 node_modules 文件夹,删除了 package-lock.json 并使用了“npm install”命令。我删除了cocoapods并重新安装。

没有什么对我有用。

我的 package.json 文件如下(仅包而不是全部)

"@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"
Run Code Online (Sandbox Code Playgroud)

我的 podfile:我记得,我从 React 63.2 降级到 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
Run Code Online (Sandbox Code Playgroud)

Ado*_*zis 4

您可能缺少react-nativenpm 模块。

您应该通过使用此命令将其包含在您的命令中packages.json,以减少将来遇到此错误的可能性。

$ npm install --save react-native
Run Code Online (Sandbox Code Playgroud)

  • 生成 RN 应用程序时会自动安装“react-native”。并且作者的`package.json`显示已经安装了。所以,这确实不是一个答案。我之所以提到它,是因为我和作者有同样的错误,并且很惊讶这是唯一提供的回复。 (4认同)