Javascript react native CLI应该是本地模块还是全局模块?
在FB的git页面上,我一直在介绍开始使用React Native的最初步骤 在这个过程中,使用nxp或npm安装的CLI,我得到了流动的错误Javascript react native CLI应该是本地模块还是全局模块?,javascript,react-native,npm,react-native-ios,react-native-cli,Javascript,React Native,Npm,React Native Ios,React Native Cli,在FB的git页面上,我一直在介绍开始使用React Native的最初步骤 在这个过程中,使用nxp或npm安装的CLI,我得到了流动的错误 [!] Invalid `Podfile` file: [!] /Users/allen/.nvm/versions/node/v12.14.1/bin/node -e console.log(require('@react-native-community/cli').bin); internal/modules/cjs/loader.js:796
[!] Invalid `Podfile` file: [!] /Users/allen/.nvm/versions/node/v12.14.1/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:
- /Volumes/BLUE/workspace-blue/react_native-blue/test/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: [ '/Volumes/BLUE/workspace-blue/react_native-blue/test/ios/[eval]' ]
}
[!]无效的'Podfile'文件:[!]/Users/allen/.nvm/versions/node/v12.14.1/bin/node-e console.log(需要('@react native community/cli').bin);
内部/modules/cjs/loader.js:796
犯错误;
^
错误:找不到模块'@react native community/cli'
需要堆栈:
-/Volumes/BLUE/workspace-BLUE/react\u native-BLUE/test/ios/[eval]
在Function.Module.\u解析文件名(internal/modules/cjs/loader.js:793:17)
at Function.Module._load(内部/modules/cjs/loader.js:686:27)
at Module.require(内部/modules/cjs/loader.js:848:19)
根据需要(internal/modules/cjs/helpers.js:74:18)
在[评估]:1:13
在Script.runInThisContext(vm.js:116:20)
在Object.runInThisContext(vm.js:306:38)
反对。([eval]-包装:9:26)
at模块编译(内部/modules/cjs/loader.js:955:30)
在evalScript(internal/process/execution.js:80:25){
代码:“未找到模块”,
requireStack:['/Volumes/BLUE/workspace BLUE/react_native-BLUE/test/ios/[eval]]]
}
这在cocoapods安装期间发生。文件说:
如果以前安装了global react native cli软件包,请将其删除,因为它可能会导致意外问题
但是,无论安装了什么或使用什么创建启动文件,都会发生这种情况
在Podfile中有以下几行:
platform :ios, '13.0' # <- this was 9.0 but I changed to 13.0
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform:ios,'13.0'#它需要是本地的。当你进入时
npx react-native init [project name]
它将在本地添加它
此官方链接建议:
如果以前安装了global react native cli软件包,请将其删除,因为它可能会导致意外问题
我尝试删除react native cli的所有全局和本地安装,但当到达cocoapods安装步骤时,init
总是失败。自从我第一次尝试跟随指南之后,它就这样做了。我已经通过自制安装了node,甚至尝试使用rbenv更改我的ruby版本。您是否使用了npx react native init[project_name]
?