Xcode 9.2 的 React Native CLI 版本

React Native CLI version for Xcode 9.2

我已经按照官方网站上关于安装 React Native 的说明进行操作了。 按照说明操作后,当我 运行 代码时,出现错误,经过一些研究后我发现这是因为我仍在使用 2011 MAC BOOK PRO 和 Xcode 版本我使用的是 Xcode 9.2,它与当前版本的 React Native 并不兼容。

我想使用旧版本的 React Native。哪个 React Native 版本与 Xcode 9.2 兼容,我应该使用哪个 React Native CLI 版本?

我尝试通过以下方式使用 CLI 安装旧版本:

react-native init Test --version 0.51

但我收到以下错误:

This will walk you through creating a new React Native project in /Users/bliss/Documents/Coder/ReactNative/Test Using yarn v1.3.2 Installing 0.51... yarn add v1.3.2 info No lockfile found. [1/4] Resolving packages... error An unexpected error occurred: "https://registry.yarnpkg.com/0.51: Not found". info If you think this is a bug, please open a bug report with the information provided in "/Users/bliss/Documents/Coder/ReactNative/Test/yarn-error.log". info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command. { Error: Command failed: yarn add 0.51 --exact at checkExecSyncError (child_process.js:629:11) at execSync (child_process.js:666:13) at run (/usr/local/lib/node_modules/react-native-cli/index.js:294:5) at createProject (/usr/local/lib/node_modules/react-native-cli/index.js:249:3) at init (/usr/local/lib/node_modules/react-native-cli/index.js:200:5) at Object. (/usr/local/lib/node_modules/react-native-cli/index.js:153:7) at Module._compile (internal/modules/cjs/loader.js:776:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) status: 1, signal: null, output: [ null, null, null ], pid: 6231,
stdout: null, stderr: null } Command yarn add 0.51 --exact failed.

您在版本中提供的格式有误。

正如您在 docs 中看到的那样,它应该是

react-native init AwesomeProject --version X.XX.X

而不是 0.51 试试 0.51.0.

您还可以检查 那里有很多答案和其他方法。