Search code examples
react-nativeexporeact-navigation-stackreact-navigation-v5

'@react-navigation/stack' has stopped working with error - unable to resolve module


I have been successfully using React Navigation Stack (V5) for about a week now and today my app will not build as the error - unable to resolve module is now shown.

Error Message

The module is installed as shown in my package.json file -

{
  "scripts": {
    "postinstall": "jetify",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "web": "expo start --web",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "@react-native-community/masked-view": "^0.1.6",
    "expo": "~36.0.0",
    "expo-linear-gradient": "^8.0.0",
    "react": "~16.9.0",
    "react-dom": "~16.9.0",
    "react-native": "~0.61.4",
    "react-native-fontawesome": "^7.0.0",
    "react-native-gesture-handler": "^1.5.6",
    "react-native-keyboard-aware-scroll-view": "^0.9.1",
    "react-native-reanimated": "^1.7.0",
    "react-native-safe-area-context": "^0.7.2",
    "react-native-screens": "^2.0.0-beta.2",
    "react-native-unimodules": "~0.7.0",
    "react-native-web": "~0.11.7",
    "react-navigation": "^4.0.10",
    "react-navigation-stack": "^1.10.3"
  },
  "devDependencies": {
    "@babel/core": "~7.6.0",
    "babel-jest": "~24.9.0",
    "jest": "~24.9.0",
    "jetifier": "~1.6.4",
    "metro-react-native-babel-preset": "~0.56.0",
    "react-test-renderer": "~16.9.0"
  },
  "jest": {
    "preset": "react-native"
  },
  "private": true
}

I have tried the following steps to try resolve the issue -

  1. Deleted node_modules
  2. Cleared yarn and npm cache
  3. Ran npm install to install dependencies again
  4. Cleared expo cache
  5. Deleted and re-downoaded expo app on iOS device
  6. Also tried installing the react navigation stack package again

Still receiving the same error message.

Would MASSIVELY appreciate any ideas.. currently losing my head over this :|


Solution

  • You don't have @react-navigation/stack or any @react-navigation/xxx packages in your package.json. You have react-navigation-xxx packages which are for v4.

    Follow the getting started guide to set it up properly https://reactnavigation.org/docs/en/getting-started.html