I am a fresh man for using react native. And I am following the get started of react native on my Mac. When I use npx react-native init AwesomeProject to create a new app, then I get a result shows me:
✔ 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/
But I have installed CocoaPods by sudo gem install cocoapods, and it shows me:
Successfully installed cocoapods-1.8.4
Parsing documentation for cocoapods-1.8.4
Done installing documentation for cocoapods after 3 seconds
1 gem installed
So What's the problem? How can I fix it? Thank you very much!