为什么在创建 React Native 应用程序时 cocoapods 依赖项安装失败?
why is cocoapods dependency installed failed when creating a react native app?
我是一个新人,使用 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
所以问题是什么?我该如何解决?非常感谢!
这是一个错误,今天早上遇到了同样的问题。我通过
修复了它
npm i @react-native-community-cli
之后我进入了 ios
文件夹并且可以 pod install
成功
我是一个新人,使用 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
所以问题是什么?我该如何解决?非常感谢!
这是一个错误,今天早上遇到了同样的问题。我通过
修复了它npm i @react-native-community-cli
之后我进入了 ios
文件夹并且可以 pod install
成功