当我在终端上运行npm start
时,我试图在我的visual studio代码上运行下面的代码,并在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
}
有人能帮帮忙吗。
发布于 2021-11-21 09:11:15
将NodeJS降级到14.18.1版本。我这样做了,这个错误消失了。
https://stackoverflow.com/questions/69881002
复制相似问题