简体   繁体   English

React-native Error: Failed to install CocoaPods dependencies for iOS project, 这是这个模板所需要的

[英]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.

相关问题 React-Native:错误:无法为iOS项目安装CocoaPods依赖项,这是该模板所需要的 - React-Native: Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template 错误:无法安装此模板所需的 iOS 项目的 CocoaPods 依赖项 - Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template 无法为 iOS 项目 React-Native 安装 CocoaPods 依赖项 - Failed to install CocoaPods dependencies for iOS project React-Native 错误无法为 ios 项目安装 CocoaPods 依赖项。 反应原生 - Error Failed to install CocoaPods dependencies for ios project. React Native 初始化 react-native 项目时无法安装 cocoapods - failure to install cocoapods when initializing a react-native project 编译源iOS依赖项以实现react-native - Compile source iOS dependencies for react-native React-Native IOS 构建在 pod 安装时出错。? - React-Native IOS build giving error on pod install.? 安装react-native-custom-segmented控件,需要安装ios框架才能进行react-native项目 - Installing react-native-custom-segmented control, need to install ios framework to react-native project 显示使用Cocoapods的Xcode项目的所有本机iOS依赖关系/框架 - Show All Native iOS Dependencies/Frameworks for an Xcode Project That Uses Cocoapods CodePush React-Native iOS失败 - CodePush react-native ios failed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM