Error: Cannot find module ‘@react-native/metro-config’
This error usually occurs when the required module ‘@react-native/metro-config’ is missing from your project’s dependencies or it is not installed correctly. Here’s how you can fix it:
-
Make sure you have declared ‘@react-native/metro-config’ as a dependency in your project’s
package.json
file. If it is not listed, you can add it manually by running the following command in your project’s root directory:npm install --save-dev @react-native/metro-config
or
yarn add --dev @react-native/metro-config
-
If the module is already present in your
package.json
file, it’s possible that it was not installed correctly. In this case, you can try removing thenode_modules
folder and reinstalling the dependencies. Run the following commands:rm -rf node_modules
npm install
or
yarn install
- Once the installation is complete, try running your project again to see if the error has been resolved.