React Native错误:安装iOS项目的CocoaPods依赖项失败,此模板需要此依赖项

4zcjmb1e  于 2022-12-24  发布在  React
关注(0)|答案(3)|浏览(289)

我试图通过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".

所以我在项目的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版本**
$ pod --version
1.8.4

有什么问题吗?
然后我删除了短语"use_native_modules",它就变得正常了。

flseospp

flseospp1#

您的错误明确指出@react-native-community/cli丢失,请使用全局安装它
npm i -g @react-native-community/cli如果仍然抛出相同的错误,则使用以下命令更新cocopod
酿造升级椰子

9rygscc1

9rygscc12#

运行以下命令:

xcode-select -p

如果未获得此路径:第一个月
然后运行以下命令

sudo xcode-select --switch /Applications/Xcode.app

再次创建新项目准备就绪。

oknrviil

oknrviil3#

您的问题表明您没有安装**@react-native-community/cli**
解决方案1:运行此命令

npm i @react-native-community/cli

更新椰子类
解决方案二:

npm start -- --reset-cache

相关问题