3

我正在使用 create-react-native-app 创建一个反应原生应用程序

npm create-react-native-app 

我将 react-native 版本更新为 0.44.0,这需要将 react 版本更新为 16.0.0-alpha.6 这是我的 package.json

{
  "name": "test",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-native-scripts": "0.0.29",
    "jest-expo": "^0.4.0",
    "react-test-renderer": "~15.5.4"
  },
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": {
    "start": "react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "node node_modules/jest/bin/jest.js --watch"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/ex-navigation": "^2.11.1",
    "babel-preset-react-native-stage-0": "^1.0.1",
    "expo": "^16.0.0",
    "react": "~16.0.0-alpha.6",
    "react-native": "0.44.0"
  }
}

运行 npm install 给我以下错误

C:\dev\repo\test>npm install
npm WARN lottie-react-native@1.1.1 requires a peer of react@>=15.3.1 but none was installed.
npm WARN react-native-maps@0.12.2 requires a peer of react@>=15.4.0 but none was installed.
npm WARN react-native-svg@4.4.1 requires a peer of react@>=15.4.0 but none was installed.
npm WARN react-static-container@1.0.1 requires a peer of react@^0.13.0 || ^0.14.0 || ^15.0.0 but none was installed.

看起来 react 版本 16.0.0-alpha.6 无法被 lottie-react-native、react-native-maps、react-native-svg 和 react-static-container 识别。我不确定是否必须满足主要版本(15),或者这些库没有使用 alpha 版本 16,或者其他什么。有谁知道如何解决这一问题?谢谢。

4

2 回答 2

0

我有一个类似的问题,实际上现在我遇到了这个问题,每当我尝试使用create-react-native-app. 我现在发现的唯一解决方案(hack)是:

  1. 删除node_modules(对我来说,仅执行 npm install 是不够的)
  2. npm install
于 2017-06-08T14:18:44.247 回答
0

我只是通过删除 node_modules 中的 react-native 文件夹并通过运行此命令重新安装 react-native 来解决相同的问题

  1. 删除 node_modules 中的 react-native 文件夹
  2. 通过运行重新安装 react-nativenpm install react-native

我认为这比删除整个 node_modules 更简单,因为只有 react-native 包及其 package.json 丢失。

于 2021-03-23T01:44:33.557 回答