【发布时间】:2023-03-09 00:14:02
【问题描述】:
我是 React Native 的新手,在处理一个旧项目时遇到此错误,在过去的几个小时内无法解决,有人请帮忙吗?
JavaScript 版本:0.50.4 原生版本:0.62.2
确保您已重建本机代码。如果问题仍然存在,请尝试使用
watchman watch-del-all && react-native start --reset-cache清除 Watchman 和打包程序缓存。
这就是我的 package.json 的样子
{
"name": "WhoopaUserApp",
"version": "0.1.0",
"private": true,
"devDependencies": {
"@babel/core": "^7.8.6",
"@babel/plugin-proposal-class-properties": "^7.10.1",
"@babel/plugin-transform-runtime": "^7.10.1",
"@babel/preset-env": "^7.10.2",
"@babel/preset-react": "^7.10.1",
"babel-preset-expo": "~8.1.0",
"babel-preset-react-native-stage-0": "^1.0.1",
"jest-expo": "^37.0.0",
"react-native-clean-project": "^3.3.0",
"react-native-cli": "^2.0.1",
"react-test-renderer": "16.0.0-alpha.12",
"redux-logger": "^3.0.6"
},
"scripts": {
"start": "react-native start",
"android": "react-native run-android",
"ios": "react-native run-ios",
"test": "node node_modules/jest/bin/jest.js --watch"
},
"jest": {
"preset": "jest-expo"
},
"rnpm": {
"assets": [
"./src/assets/fonts/"
]
},
"dependencies": {
"@sentry/react-native": "^1.4.1",
"ac-qrcode": "^1.0.1",
"babel-preset-react-native": "^4.0.1",
"errno": "^0.1.7",
"expo": "^37.0.3",
"fetchival": "^0.3.3",
"glob": "^7.1.6",
"immutability-helper": "^2.4.0",
"jsc-android": "^241213.1.0",
"metro-react-native-babel-preset": "^0.59.0",
"normalizr": "^3.2.4",
"numeral": "^2.0.6",
"prop-types": "^15.6.0",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-native": "^0.61.4",
"react-native-cached-image": "^1.4.3",
"react-native-camera": "git+https://git@github.com/react-native-community/react-native-camera.git",
"react-native-config": "^0.10.0",
"react-native-easy-toast": "^1.1.0",
"react-native-fbsdk": "^0.6.3",
"react-native-fetch-blob": "^0.10.8",
"react-native-gesture-handler": "^1.6.1",
"react-native-google-signin": "^0.12.0",
"react-native-i18n": "^2.0.9",
"react-native-maps": "0.26.1",
"react-native-modal": "^4.0.0",
"react-native-orientation": "^3.1.0",
"react-native-popup-dialog": "^0.10.43",
"react-native-progress": "^3.4.0",
"react-native-reanimated": "~1.7.0",
"react-native-responsive-dimensions": "^1.0.2",
"react-native-router-flux": "^4.0.0-beta.24",
"react-native-screens": "~2.2.0",
"react-native-scrollable-tab-view": "^0.8.0",
"react-native-splash-screen": "3.0.6",
"react-native-swipe-list-view": "^1.0.4",
"react-native-swipe-out": "^2.0.14",
"react-native-swipeable": "^0.6.0",
"react-native-swipeview": "^1.0.3",
"react-native-swiping-row": "^0.1.2",
"react-native-update-js": "^1.0.8",
"react-native-vector-icons": "^6.6.0",
"react-native-web": "^0.12.2",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-persist": "^5.4.0",
"redux-saga": "^0.16.0",
"reselect": "^3.0.1"
}
}
【问题讨论】:
-
已经 4 天了。我仍在为这个错误而苦苦挣扎。
-
您有一个旧的 Metro 捆绑器实例正在运行。关闭它并再次运行
react-native android或react-native ios。如果找不到,请重新启动计算机。 -
重启电脑试了很多次。你能解释一下吗?
-
错误信息表示项目使用的是React Native 0.50.4版本,但手机或模拟器使用的是0.62.2版本。如果您使用的是 react-native-cli 的全局实例,则它的版本可能与项目版本不匹配。
-
感谢您的回复@GuyIncognito。我已经更新了添加
package.json的问题我已经将我的react-native 版本从0.62.2降级为^0.61.4,正如您在我的package.json 文件中看到的那样。我如何更新我的 Java Script 版本以更新以满足我的 react-native 版本的匹配。
标签: javascript reactjs react-native