反应本机版本不匹配0.60.4

时间:2019-08-01 14:40:45

标签: react-native react-native-android react-native-ios

升级到react-native:0.60.4后,我无法运行我的应用,并且出现了react-native版本不匹配错误。

package.json

{
  "name": "abcd",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.6.1",
    "jetifier": "^1.6.3",
    "moment": "^2.24.0",
    "react": "16.8.3",
    "react-native": "^0.60.4",
    "react-native-btr": "^1.1.4",
    "react-native-document-picker": "^2.3.0",
    "react-native-elements": "^1.1.0",
    "react-native-gesture-handler": "^1.3.0",
    "react-native-material-dropdown": "^0.11.1",
    "react-native-modal-overlay": "^1.3.1",
    "react-native-progress": "^3.6.0",
    "react-native-progress-bar": "^0.1.2",
    "react-native-screens": "^1.0.0-alpha.22",
    "react-native-searchable-dropdown": "^1.1.1",
    "react-native-simple-dialogs": "^1.1.0",
    "react-native-table-component": "^1.2.0",
    "react-native-vector-icons": "^6.6.0",
    "react-navigation": "^3.8.1",
    "react-navigation-fluid-transitions": "^0.3.1"
  },
  "devDependencies": {
    "@babel/core": "7.4.3",
    "@babel/runtime": "7.4.3",
    "babel-jest": "24.7.1",
    "jest": "24.7.1",
    "metro-react-native-babel-preset": "0.53.1",
    "react-test-renderer": "16.8.6",
    "reactotron-react-native": "^3.2.2",
    "reactotron-redux": "^3.1.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

Error Image

4 个答案:

答案 0 :(得分:1)

1- 关闭所有终端 / bash屏幕

2-打开新的bash并转到项目文件夹

cd ~/Documents/projects/myProject

3- 运行您的项目

react-native run-ios //react-native run-android

4- npm在您的路径上开始

myProject$ npm start

最好!

答案 1 :(得分:1)

对此没有确切的解决方案,因为所有系统以及安装和变体版本都是无止境的。

error screenshot here

因此,为了最好地解决此问题而又不拔头发,是

  1. 使用react-native更新您的npx react-native upgrade
  2. 以防万一也像这样npm install -g react-native-cli
  3. 在您的系统上全局安装React Native
  4. 然后使用npx react-native init AwesomeProject
  5. 创建一个全新的EXPO或React Native项目
  6. 然后在您的package.json中查看新项目中reactreact-native的版本,并将它们与您的工作项目进行比较

例如这是我的工作项目

        "expo-barcode-scanner": "~8.2.1",
        "expo-linear-gradient": "~8.2.1",
        "expo-status-bar": "^1.0.2",
        "react": "~16.11.0",
        "react-dom": "~16.11.0",
        "react-native": "^0.61.4",

这是我的新项目Package.json

    "expo-splash-screen": "^0.5.0",
    "expo-status-bar": "^1.0.0",
    "expo-updates": "~0.2.10",
    "react": "~16.11.0",
    "react-dom": "~16.11.0",
    "react-native": "~0.62.2",

然后,最后我使用了新项目中的reactreact-native版本,它们都运行良好

这是我工作项目的最终代码

        "expo-barcode-scanner": "~8.2.1",
        "expo-linear-gradient": "~8.2.1",
        "expo-status-bar": "^1.0.2",
        "react": "~16.11.0",
        "react-dom": "~16.11.0",
        "react-native": "~0.62.2",

答案 2 :(得分:0)

有可能要执行的请求消息正确。执行消息。

watchman watch-del-all && react-native start --reset-cache

答案 3 :(得分:0)

最后我用自己的方式解决了。

  1. 创建另一个空项目
  2. 将您的资源+ packages.json复制到新项目中
  3. 不要在新项目中安装npm

问题解决了。