我试图通过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”,它变得很正常。
答案 0 :(得分:0)
您的错误清楚地表明@react-native-community/cli 缺少使用
全局安装它npm i -g @react-native-community/cli 如果仍然抛出相同的错误,请使用
更新 cocoapodsbrew 升级 cocoapods