Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to resolve dependency tree when installing @react-navigation/[email protected]

I created a new project react-native init MyProject and after opening it in VSCode the first thing I did was to install the navigation.

npm install @react-navigation/native @react-navigation/stack

It throws the error, then I did it separately meaning first I did npm install @react-navigation/native it gets installed successfully then after this I did npm install @react-navigation/stack then the error came again:

 npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency
 tree npm ERR!  npm ERR! While resolving: [email protected] npm ERR!
 Found: [email protected] npm ERR! node_modules/react npm ERR!  
 react@"17.0.1" from the root project npm ERR!   peer react@"*" from
 @react-navigation/[email protected] npm ERR!  
 node_modules/@react-navigation/stack npm ERR!    
 @react-navigation/stack@"^5.14.2" from the root project npm ERR!  npm
 ERR! Could not resolve dependency: npm ERR! peer react@"^16.0" from
 @react-native-community/[email protected] npm ERR!
 node_modules/@react-native-community/masked-view npm ERR!  
 @react-native-community/masked-view@"^0.1.10" from the root project
 npm ERR!   peer @react-native-community/masked-view@">= 0.1.0" from  
 @react-navigation/[email protected] npm ERR!  
 node_modules/@react-navigation/stack npm ERR!    
 @react-navigation/stack@"^5.14.2" from the root project npm ERR!  npm
 ERR! Fix the upstream dependency conflict, or retry npm ERR! this
 command with --force, or --legacy-peer-deps npm ERR! to accept an
 incorrect (and potentially broken) dependency resolution. npm ERR! 
 npm ERR! See /Users/chaudhrytalha/.npm/eresolve-report.txt for a full
 report.
 
 npm ERR! A complete log of this run can be found in: npm ERR!    
 /Users/chaudhrytalha/.npm/_logs/2021-03-17T10_09_02_128Z-debug.log

I even tried installing npm install @react-native-community/masked-view but get similar errors.

like image 858
Chaudhry Talha Avatar asked Mar 17 '21 10:03

Chaudhry Talha


People also ask

How do I resolve NPM dependency errors?

The easiest way to fix the issue is to pass an additional parameter –legacy-peer-deps to npm install. The --legacy-peer-deps tells the npm to ignore the peer dependencies and continue the installation of the package.

Why installing @react-navigation/stack fails?

Installing @react-navigation/stack fails due to dependency error. I've just created a new react-native application following these steps: npm ERR! code ERESOLVE npm ERR!

What does “eresolve unable to resolve dependency tree error” mean?

When you try to install an Angular or React JS application you may get the error message “ERESOLVE unable to resolve dependency tree error” in your command prompt. The reason for the error message is because of a dependency conflict.

Why am I getting an error when running a React Native application?

A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native. ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication).

How do I resolve the upstream dependency conflict with npm err?

Fix the upstream dependency conflict, or retry npm ERR! this command with --force, or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! See C:\Users\campo\AppData\Local pm-cache\eresolve-report.txt for a full report. npm ERR!


Video Answer


3 Answers

This will solve the issue

npm install --legecy-peer-deps @react-navigation/stack --force

like image 188
chandru Avatar answered Nov 09 '22 22:11

chandru


Using yarn instead of npm is solved my issue.

like image 22
bilarslan Avatar answered Nov 09 '22 22:11

bilarslan


Use yarn package manager

 npm install --global yarn

use yarn to resolve your package.json deps

yarn install
like image 28
Difatha T. Kariuki Avatar answered Nov 09 '22 21:11

Difatha T. Kariuki