Troubleshooting
This section attempts to outline issues that users frequently encounter when first getting accustomed to using React Navigation. These issues may or may not be related to React Navigation itself.
Before troubleshooting an issue, make sure that you have upgraded to the latest available versions of the packages. You can install the latest versions by installing the packages again (e.g. npm install package-name
).
I'm getting an error "Unable to resolve module" after updating to the latest version
This might happen for 3 reasons:
Stale cache of Metro bundler
If the module points to a local file (i.e. the name of the module starts with ./
), then it's probably due to stale cache. To fix this, try the following solutions.
If you're using Expo, run:
expo start -c
If you're not using Expo, run:
npx react-native start --reset-cache
If that doesn't work, you can also try the following:
rm -rf $TMPDIR/metro-bundler-cache-*
Missing peer dependency
If the module points to an npm package (i.e. the name of the module doesn't with ./
), then it's probably due to a missing dependency. To fix this, install the dependency in your project:
- npm
- Yarn
- pnpm
npm install name-of-the-module
yarn add name-of-the-module
pnpm add name-of-the-module
Sometimes it might even be due to a corrupt installation. If clearing cache didn't work, try deleting your node_modules
folder and run npm install
again.