[英]React Native - console.error: 'React Native version mismatch
I am using EXPO and React Native, the app work running completely fine until it suddenly stopped when I made a new file and even when I deleted it, the error stayed.我正在使用 EXPO 和 React Native,应用程序运行完全正常,直到我创建一个新文件时它突然停止,即使我删除它,错误仍然存在。
I have updated React Native to V0.56.0 but it is still showing the error:我已将 React Native 更新到 V0.56.0,但它仍然显示错误:
console.error: 'React Native version mismatch.
console.error: 'React Native 版本不匹配。
Javascript version: 0.56.0 Native Version: 0.52.0 Javascript 版本:0.56.0 原生版本:0.52.0
Before I updated it was:在我更新之前它是:
Javascript version: 0.54.0 Native Version: 0.52.0 Javascript 版本:0.54.0 原生版本:0.52.0
and still causing the same error?仍然导致相同的错误?
Any ideas on how I fix this and which command I use to update the Native Version?关于如何解决此问题以及我使用哪个命令来更新本机版本的任何想法?
Go to package.json
file inside your project folder转到项目文件夹中的
package.json
文件
Where you can find code like this在哪里可以找到这样的代码
"dependencies": {
.....
"react-native": "^0.54.0",
......
},
change the react-native
version to 0.54
and save file.将
react-native
版本更改为0.54
并保存文件。
Then go to the terminal and redirect to your project folder and hit the command然后转到终端并重定向到您的项目文件夹并点击命令
npm install && expo start -c
This Answer is Published in 2020 and updated in 2021, Fix this Error in 3 steps:此答案于 2020 年发布并于 2021 年更新,分 3 个步骤修复此错误:
First step: I changed the value of expo
in package.json
file to the latest supported version, according to expo documents(visit here ).第一步:根据 expo 文档(请访问这里),我将
package.json
文件中expo
的值更改为最新支持的版本。
Second step: I changed the value of sdkVersion
in app.json
file to the same value of expo
in package.json
.( equal number to last step).第二步:我将
app.json
文件中sdkVersion
的值改为package.json
中expo
的相同值。(与上一步相同)。
Third step : I changed the value of react-native
in package.json
file to the same value of React Native Version
, according to expo documents(visit here ).第三步:根据expo文档(请访问这里),我将
package.json
文件中react-native
的值更改为与React Native Version
相同的值。
now your ready to go.现在你准备好了。
use npm install
to install specified version of dependencies and then npm start
to run the project使用
npm install
安装指定版本的依赖,然后npm start
运行项目
I have used something like this我用过这样的东西
$ sudo npm install babel-upgrade -g
$ react-native-git-upgrade
$ npx babel-upgrade --write
$ sudo npm install babel-upgrade -g
$ npx babel-upgrade --write --install
$ react-native-git-upgrade
$ watchman watch-del-all
$ rm -rf node_modules
$ rm -rf $TMPDIR/react-*
$ rm -rf ios/Pods
$ cd ios
$ pod cache clean --all
$ pod repo update && pod install
$ cd ..
$ npm install
$ ./android/gradlew clean -p ./android/
$ rm -rf ios/build
$ react-native run-ios
$ react-native run-android
$ cd ios/
$ pod update yoga
$ pod update React/RCTNetwork
$ pod repo update
$ pod update
$ cd ..
$ pod update
$ cd ..
$ react-native run-ios
Javascript was one version behind the installed native version, Javascript 是安装的本机版本之后的一个版本,
So, I changed the sdk version to just 1 behind Changed this line in my package.json "react-native": "https://github.com/expo/react-native/archive/sdk-38.0.0.tar.gz",因此,我将 sdk 版本更改为仅 1 在我的 package.json “react-native”中更改了这一行:“https://github.com/expo/react-native/archive/sdk-38.0.0.tar。 gz",
to "react-native": "https://github.com/expo/react-native/archive/sdk-37.0.0.tar.gz",到“反应原生”:“https://github.com/expo/react-native/archive/sdk-37.0.0.tar.gz”,
and saved the file, and app started working (Didn't even restart the app)并保存文件,应用程序开始工作(甚至没有重新启动应用程序)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.