This version of '@react-navigation/native' is not compatible with React Navigation 5

Viewed 1137

I have installed react-navigation via

npm install react-navigation

then i have installed @react-navigation/native via

npm install @react-navigation/native

but got an error

This version of '@react-navigation/native' is not compatible with React Navigation 5. Make sure you install 5.x version of @react-navigation/native

npm -v @react-navigation/native
6.14.4
npm -v react-navigation
6.14.4
2 Answers

In your app's package.json file check following dependencies and their versions. For me following resolved the above issue.

 "dependencies": {
"@react-native-community/masked-view": "0.1.6",
"@react-navigation/native": "^5.5.1",
"@react-navigation/stack": "^5.5.1",
"babel-runtime": "^6.26.0",
"expo": "~37.0.3",
"react": "~16.9.0",
"react-dom": "~16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
"react-native-gesture-handler": "~1.6.0",
"react-native-reanimated": "~1.7.0",
"react-native-safe-area-context": "0.7.3",
"react-native-screens": "~2.2.0",
"react-native-web": "~0.11.7",
"react-navigation": "^4.3.9"

}

you can't use @react-navigation/native v5 and react-navigation together cause the react-navigation package is no longer being used after v4.

every module you want to use must have been installed separately.

for Example: @react-navigation/stack, @react-navigation/bottom-tabs, @..../drawer , ...

You either need some peer dependencies installed.

react-native-screens to handle high performance navigation

react-native-reanimated to handle transitions animations when you navigate through pages

react-native-gesture-handler to handle navigations through pan gestures

react-native-safe-area-context to handle screen controls

@react-native-community/masked-view to handle particular styles on the header of the stack navigator

@react-native-community/toolbar-android this is the android toolbar widget, you need to install it because it's being removed from 'react-native' core package from version 0.61

Related