Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native Version Mismatch Error

Tags:

react-native

I am trying to run a react native application using the following command.

npm run android

I get the following error.

enter image description here

im using nvm - nvm use stable

Now using node v8.9.4 (npm v4.6.1)

**package.json**

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-native-scripts": "1.11.0",
    "jest-expo": "23.0.0",
    "react-test-renderer": "16.0.0"
  },
  "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": "^23.0.4",
    "react": "16.0.0",
    "react-native": "0.50.3"
  }
}

A different solution recommended rerunning the build process because there maybe some interference, but this did not work for me.

like image 507
Kay Avatar asked Jan 28 '23 19:01

Kay


2 Answers

I managed to solve this my self. The error message was showing a react-native version of 0.50.3.

But the latest version is 0.52 as can be seen here https://facebook.github.io/react-native/versions.html.

So i updated package json to reflect this.

  "dependencies": {

    "react-native": "0.52"
  }

then i deleted npm modules and reran npm install. This fixed my issue.

tldr; update package.json react-native dependency to reflect latest version.

like image 146
Kay Avatar answered Feb 05 '23 16:02

Kay


I Had the same problem, and the KHAN give us the right solution.

I'm Putting here the package.json for thoses who need the fix:

{
  "name": "project",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-native-scripts": "1.11.0",
    "jest-expo": "25.0.0",
    "react-test-renderer": "16.0.0"
  },
  "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": "^25.0.0",
    "react": "16.0.0",
    "react-native": "0.52"
  }
}
like image 41
Henrique Braga Avatar answered Feb 05 '23 15:02

Henrique Braga