I was trying npm install i got the error as –
# npm install
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! dev react@"^17.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.0.0-0" from [email protected]
npm ERR! node_modules/enzyme-adapter-react-16
npm ERR! enzyme-adapter-react-16@"^1.15.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.
I tried using npm install –force and npm install –legacy–peer-deps
then got the error as –
# npm install --force
npm WARN using --force Recommended protections disabled.
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! network Socket timeout
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
also tried changing max min timeout … but didnt work
when search on google i found some yarn cmd , but am not sure what yarn does ..
can anyone please help me out ….
2
Answers
For 1st problem:
It’s package dependencies problem.
It’s look like you use React 17 (Found: [email protected]). But module enzyme-adapter-react-16 need React 16.
Solution: downgrade react to version 16 or change enzyme-adapter-react-16 to enzyme-adapter-react-17.
From the enzyme-adapter-react-16 documentation, we know:
But the
react
version is^17.0.2
in your project, which is an incompatible version.Two solutions:
Downgrading the
react
package to the^16.4.0
version.Use @wojtekmaj/enzyme-adapter-react-17 package, an unofficial adapter for React 17 for Enzyme.
Unfounaly, there is no official adapter for
React 17.x
andReact 18.x
Further reading: