Been using NPM version of 6.14.7 and decided to move on with NPM version 7.20.1 for my react-native project. Soonest as I try npm install, most of my libraries break with the error of Could not resolve dependency:
Example(s)
// example 1
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8" from @react-native-community/async-storage@1.12.1
// example 2
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.0" from @react-native-community/picker@1.8.1
// More Example(s)
..
...
.....
FYI, am aware the breaking change of peer dependencies announcement made by NPM team. Need some guidance here, how can I upgrade my npm version seamlessly?
Automatically installing peer dependencies is an exciting new feature introduced in npm 7. In previous versions of npm (4-6), peer dependencies conflicts presented a warning that versions were not compatible, but would still install dependencies without an error. npm 7 will block installations if an upstream dependency conflict is present that cannot be automatically resolved.
Of course, I'm aware with the following options. If I were to execute npm install --legacy-peer-deps, isn't this the same as if Im using NPM 6? Since it's only by passing the auto installation peer dependencies.
You have the option to retry with --force to bypass the conflict or --legacy-peer-deps command to ignore peer dependencies entirely (this behavior is similar to versions 4-6).
Decision
Just to share my thoughts, hopefully to help others.
After more read up (link1, link2)over NPM7 and comments shared by @Dan Macák and @M. Erim Tuzcuoglu, I've decided to stay with NPM6 for the moment.
Mainly I think the efforts and risk is way higher than the rewards by upgrading to NPM7? I anyway don't need the new features shipped in NPM7
I have also tried using NVM suggested by @M. Erim Tuzcuoglu, then switch using different NVM + NPM eventually hitting 1 issue from xcode (Command PhaseScriptExecution failed with a nonzero exit code). I think the reason was nvm is not compatible with the "PREFIX" Many has faced this issue and came up with some solutions, but I've decided not to go further as it seems complicating the project further (other team members would need to do the same settings of NVM)