我是使用React Native的新鲜人。我正在Mac上开始本机反应。当我使用npx react-native初始化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
那是什么问题?我该如何解决?非常感谢!
答案 0 :(得分:0)
这是一个错误,今天早上有同样的问题。我通过做固定了
npm i @react-native-community-cli
之后,我进入了ios
文件夹,可以成功完成pod install