无法创建新项目并升级到React Native版本最新0.69.1

Muh*_*sim 5 npm reactjs react-native

我们无法使用 React Native 最新版本 0.69.1 创建新项目。我用旧版本创建了新项目。然后我升级到0.69.1。npx 反应本机升级。但我无法完全升级。当我运行npm i命令时。错误来了

npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-test-renderer@17.0.2
npm ERR! Found: react@18.0.0
npm ERR! node_modules/react
npm ERR!   react@"18.0.0" from the root project
npm ERR!   peer react@"18.0.0" from react-native@0.69.1
npm ERR!   node_modules/react-native
npm ERR!     react-native@"0.69.1" from the root project
npm ERR!     peer react-native@"*" from @react-native-community/cli@8.0.2
npm ERR!     node_modules/@react-native-community/cli
npm ERR!       @react-native-community/cli@"^8.0.0" from react-native@0.69.1
npm ERR!     2 more (react-native-call-detection, react-native-get-sms-android)
npm ERR!   1 more (use-sync-external-store)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.2" from react-test-renderer@17.0.2
npm ERR! node_modules/react-test-renderer
npm ERR!   dev react-test-renderer@"17.0.2" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react@17.0.2
npm ERR! node_modules/react
npm ERR!   peer react@"17.0.2" from react-test-renderer@17.0.2
npm ERR!   node_modules/react-test-renderer
npm ERR!     dev react-test-renderer@"17.0.2" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Latif\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Latif\AppData\Local\npm-cache\_logs\2022-07-03T09_00_20_794Z-debug-0.log
Run Code Online (Sandbox Code Playgroud)

如何升级到 React Native 的最新版本(0.69.1)?

DHR*_*JWA 11

您必须删除当前的react-native 库并安装新的库。

以下命令集对我有用

  1. npm uninstall -g 反应本机-cli
  2. npm uninstall -g 反应本机
  3. npm install -g 反应本机
  4. npm 升级-g