react-native - TypeError:尝试更改不可配置属性的 getter
问题描述
我正在尝试在我的 Visual Studio 代码上运行以下代码,并npm start
在我的终端上运行时在 Expo 客户端中出现以下错误。
import { createStackNavigator, createAppContainer } from 'react-navigation';
import CategoriesScreen from '../screens/CategoriesScreen';
import CategoryItemsScreen from '../screens/CategoryItemsScreen';
const ItemsNavigator = createStackNavigator({
Categories: CategoriesScreen,
CategoryItems: {
screen: CategoryItemsScreen
}
});
export default createAppContainer(ItemsNavigator);
下面是我得到的错误
TypeError: Attempting to change the getter of an unconfigurable property.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:172:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules/metro-runtime/src/polyfills/require.js:204:6 in guardedLoadModule
at http://192.168.0.109:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&minify=false:126726:3 in global code
Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:172:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError
我的 package.json 如下
"dependencies": {
"@react-native-community/masked-view": "^0.1.11",
"@react-navigation/native": "^6.0.6",
"expo": "~43.0.0",
"expo-app-loading": "~1.2.1",
"expo-font": "~10.0.3",
"expo-status-bar": "~1.1.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.2",
"react-native-gesture-handler": "~1.10.2",
"react-native-reanimated": "~2.2.0",
"react-native-safe-area-context": "^3.3.2",
"react-native-screens": "~3.8.0",
"react-native-web": "0.17.1",
"react-navigation": "^4.4.4",
"react-navigation-stack": "^2.10.4"
},
"devDependencies": {
"@babel/core": "^7.12.9"
},
"private": true
}
有人可以帮忙吗。
解决方案
将 NodeJS 降级到 14.18.1 版本。我做到了,这个错误消失了
推荐阅读
- javascript - 单一职责原则 React 重构
- r - 将 201401(数字)更改为 R 中的日期变量
- c++ - Visual Studio 不支持自动模板参数是否有解决方法?
- mysql - 将csv文件加载到服务器上的mysql中
- pandas - 在熊猫中打开具有单行 6M 值的 csv 非常慢
- reactjs - Reactjs 使用下拉菜单记录返回错误意外令牌
- awk - 使用 awk 打印文件中模式的索引
- java - 在哪里设置 VERTICAL_SCROLLBAR_NEVER?
- c++ - math.h 中的 C/C++ log10 函数产生不正确的值
- python-3.x - spacy错误:找不到一些strings.json