[英]React-native Error : Failed to install CocoaPods dependencies for iOS project, which is required by this template
I tried to create a project through npx
, but an error occurred.我尝试通过
npx
创建项目,但出现错误。
$ npx react-native init springtesting
error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Please try again manually: "cd ./springtesting/ios && pod install".
So I executed a sentence inside the ios folder in the project.于是在项目中的ios文件夹里面执行了一句。
$ pod install
[!] Invalid `Podfile` file: [!] /usr/local/bin/node -e console.log(require('@react-native-community/cli').bin);
internal/modules/cjs/loader.js:983
throw err;
^
Error: Cannot find module '@react-native-community/cli'
Require stack:
- /Users/myname/springtesting/ios/[eval]
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
at Function.Module._load (internal/modules/cjs/loader.js:862:27)
at Module.require (internal/modules/cjs/loader.js:1040:19)
at require (internal/modules/cjs/helpers.js:72:18)
at [eval]:1:13
at Script.runInThisContext (vm.js:120:20)
at Object.runInThisContext (vm.js:311:38)
at Object.<anonymous> ([eval]-wrapper:10:26)
at Module._compile (internal/modules/cjs/loader.js:1151:30)
at evalScript (internal/process/execution.js:94:25) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/User/myname/springtesting/ios/[eval]' ]
}
.
# from /Users/taehong/springtesting/ios/Podfile:42
# -------------------------------------------
#
> use_native_modules!
# end
# -------------------------------------------
Pod version吊舱版本
$ pod --version
1.8.4
What's the problem?有什么问题?
And then i deleted the phrase 'use_native_modules' and it became normal.然后我删除了短语“use_native_modules”,它变得正常了。
Your error clearly states @react-native-community/cli is missing install it globally using您的错误明确指出 @react-native-community/cli 缺少使用
npm i -g @react-native-community/cli If still it throws the same error update the cocoapods using npm i -g @react-native-community/cli 如果仍然抛出相同的错误,请使用更新 cocoapods
brew upgrade cocoapods brew 升级 cocoapods
run this:运行这个:
xcode-select -p
if you do not get this path: Xcode.app/Contents/Developer
如果你没有得到这个路径:
Xcode.app/Contents/Developer
then run this command然后运行这个命令
sudo xcode-select --switch /Applications/Xcode.app
create again new project Good to go..再次创建新项目好去..
Your question shows that you didn't install @react-native-community/cli
你的问题表明你没有安装@react-native-community/cli
Solution 1: run this command
解决方案 1:运行此命令
npm i @react-native-community/cli
update the cocoapods
更新可可足类
Solution 2:解决方案 2:
npm start -- --reset-cache
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.