I've gone through What does npm install --legacy-peer-deps do exactly? When is it recommended / What's a potential use case? and Why use peer dependencies in npm for plugins?. I understand the reason for this issue but I don't understand why is it throwing warning for some dependencies and error for others like below
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: ts-jest@25.5.1
npm WARN Found: typescript@4.4.4
npm WARN node_modules/typescript
npm WARN typescript@"~4.4.3" from the root project
npm WARN 4 more (<someLib>
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer typescript@">=3.4 <4.0" from ts-jest@25.5.1
npm WARN node_modules/ts-jest
npm WARN ts-jest@"^25.5.1" from <someLib>
npm WARN node_modules/<someLib>
npm WARN
npm WARN Conflicting peer dependency: typescript@3.9.10
npm WARN node_modules/typescript
npm WARN peer typescript@">=3.4 <4.0" from ts-jest@25.5.1
npm WARN node_modules/ts-jest
npm WARN ts-jest@"^25.5.1" from <someLib>
npm WARN node_modules/<someLib>
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: xterm-for-react@1.0.4
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR! react@"~17.0.2" from the root project
npm ERR! peerOptional react@"^16.8.0 || ^17.0.0" from @apollo/client@3.4.17
npm ERR! node_modules/@apollo/client
npm ERR! @apollo/client@"~3.4.17" from the root project
npm ERR! @apollo/client@"~3.4.17" from <someLib>
npm ERR! node_modules/<someLib>
npm ERR! <someLib>
npm ERR! 1 more (<someLib>
npm ERR! 1 more (<someLib>
npm ERR! 33 more (@fluentui/react-hooks, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.0.0" from xterm-for-react@1.0.4
npm ERR! node_modules/xterm-for-react
npm ERR! xterm-for-react@"^1.0.4" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react@16.14.0
npm ERR! node_modules/react
npm ERR! peer react@"^16.0.0" from xterm-for-react@1.0.4
npm ERR! node_modules/xterm-for-react
npm ERR! xterm-for-react@"^1.0.4" 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.