【问题标题】:why is cocoapods dependency installed failed when creating a react native app?为什么在创建反应原生应用程序时安装 cocoapods 依赖项失败?
【发布时间】:2020-05-30 05:15:28
【问题描述】:

我是使用 react native 的新手。我正在关注我的 Mac 上的 react native 入门。当我使用 npx react-native init AwesomeProject 创建一个新应用程序时,我得到一个结果显示:

✔ Downloading template
✔ Copying template
✔ Processing template
⠋ Installing CocoaPods dependencies (this may take a few minutes)
[!] Invalid `Podfile` file: [!] /usr/local/bin/node -e console.log(require('@react-native-community/cli').bin);

internal/modules/cjs/loader.js:796
    throw err;
    ^

Error: Cannot find module '@react-native-community/cli'
Require stack:
- /Users/rionay/Desktop/react-native/AwesomeProject/ios/[eval]
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at [eval]:1:13
    at Script.runInThisContext (vm.js:116:20)
    at Object.runInThisContext (vm.js:306:38)
    at Object.<anonymous> ([eval]-wrapper:9:26)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at evalScript (internal/process/execution.js:80:25) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/Users/rionay/Desktop/react-native/AwesomeProject/ios/[eval]' ]
}
.

 #  from /Users/rionay/Desktop/react-native/AwesomeProject/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 ./AwesomeProject/ios && pod install".
CocoaPods documentation: https://cocoapods.org/

但我已经通过 sudo gem install cocoapods 安装了 CocoaPods,它显示了我:

Successfully installed cocoapods-1.8.4
Parsing documentation for cocoapods-1.8.4
Done installing documentation for cocoapods after 3 seconds
1 gem installed

那么问题是什么?我该如何解决?非常感谢!

【问题讨论】:

  • 这是 RN 中的一个错误。

标签: ios xcode macos react-native cocoapods


【解决方案1】:

这是一个错误,今天早上遇到了同样的问题。我通过这样做来修复它

npm i @react-native-community-cli

之后我进入ios 文件夹并可以成功地执行pod install

【讨论】:

  • npm i g @react-native-community/cli 应该可以解决问题。您应该全局安装它。
猜你喜欢
  • 2017-10-06
  • 1970-01-01
  • 2019-11-30
  • 2022-07-31
  • 2015-11-22
  • 1970-01-01
  • 1970-01-01
  • 2020-11-08
  • 1970-01-01
相关资源
最近更新 更多