To resolve conflicting dependencies in your project, follow these steps:
In this order install dependency
npx @react-native-community/cli init Motosharereact
npm install -g @react-native-community/cli
# Install React Native core dependencies
npm install react react-native
# Install navigation libraries
npm install @react-navigation/native @react-navigation/stack @react-navigation/drawer @react-navigation/bottom-tabs
# Install gesture handler and other navigation dependencies
npm install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context
# Install other libraries
npm install @react-native-async-storage/async-storage @react-native-community/masked-view axios react-native-paper react-native-picker-select react-native-share
npm install redux react-redux
npm install redux @reduxjs/toolkit
npm install react-native-document-picker
npx react-native run-android
============or===========
C:\Users\rakes\AppData\Local\Android\Sdk\emulator>emulator -avd Pixel_8_API_34
npx react-native run-android
Another way to start to rect native app
git bash terminal 1:npx react-native start --reset-cache
gitbash terminal-2:npx react-native run-android
How to install icons
npm install react-native-vector-icons --save
Open android/app/build.gradle
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
npx react-native run-android
- Analyze the Dependency Conflict Use the npm ls command to identify where the conflict lies in your dependency tree. For example:
npm ls react
This will show which packages depend on conflicting versions of React or other dependencies.
- Strategies to Resolve Conflicts Option 1: Manually Adjust package.json Update your package.json to specify compatible versions of conflicting dependencies.
Example:
"dependencies": {
"react": "19.1.0",
"react-native": "0.79.0"
}
Then reinstall dependencies:
rm -rf node_modules package-lock.json
npm install
Option 2: Use --legacy-peer-deps
If you want to bypass strict peer dependency checks, use:
npm install --legacy-peer-deps
This tells npm to ignore peer dependency conflicts and proceed with installation.
Option 3: Use --force
Force installation, even if conflicts exist:
npm install --force
Note: This may lead to broken dependencies, so use it cautiously.
Option 4: Upgrade Conflicting Packages
Identify outdated dependencies and update them to compatible versions:
npm outdated
npm install <package-name>@latest
Example:
npm install react@19.1.0 react-native@0.79.0
Option 5: Use Yarn Instead of npm
Yarn has better dependency conflict resolution:
npm install -g yarn
rm -rf node_modules package-lock.json
yarn install
- Clean Up the Project Clear caches and ensure a fresh installation:
rm -rf node_modules package-lock.json
npm cache clean --force
npm install --legacy-peer-deps
- Advanced Techniques Force Resolutions in package.json You can force specific versions of dependencies using the resolutions field (works with Yarn):
"resolutions": {
"react-dom": "19.1.0"
}
- Collaborate with Maintainers If the conflict persists due to outdated packages, consider opening an issue with the package maintainers or checking for forks or alternatives that resolve the conflict.
By following these steps, you should be able to resolve dependency conflicts effectively while minimizing potential issues in your project.
Dependency Checking Script
Add a script to your package.json to check for mismatches:
// scripts/check-versions.js
const pkg = require('../package.json');
const reactVersion = pkg.dependencies.react;
const rendererVersion = pkg.dependencies['react-native-renderer'];
if (reactVersion !== rendererVersion) {
console.error(`⚠️ Version mismatch detected:
- react: ${reactVersion}
- react-native-renderer: ${rendererVersion}
These versions must match exactly.`);
process.exit(1);
}
console.log('✅ React version check passed!');
Then add to your package.json:
"scripts": {
"prestart": "node scripts/check-versions.js",
// other scripts...
}
Top comments (0)