Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure installing enzyme-adapter-react-16 with react 16.13.1 #2513

Open
1 of 10 tasks
TommyLeong opened this issue Apr 7, 2021 · 3 comments
Open
1 of 10 tasks

Failure installing enzyme-adapter-react-16 with react 16.13.1 #2513

TommyLeong opened this issue Apr 7, 2021 · 3 comments

Comments

@TommyLeong
Copy link

Current behavior

Tried to install enzyme-adapter-react-16 with React-Native Version 0.63.2 and React 16.13.1

Installation command
npm i --save-dev enzyme-adapter-react-16

Error received

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@"16.13.1" from the root project
npm ERR!   peer react@"^16.0.0-0" from [email protected]
npm ERR!   node_modules/enzyme-adapter-react-16
npm ERR!     dev enzyme-adapter-react-16@"*" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.14.0" from [email protected]
npm ERR! node_modules/react-dom
npm ERR!   react-dom@"^16.13.1" from the root project
npm ERR!   peer react-dom@"^16.0.0-0" from [email protected]
npm ERR!   node_modules/enzyme-adapter-react-16
npm ERR!     dev enzyme-adapter-react-16@"*" 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.

Expected behavior

To install successfully

Your environment

Package.json

"react": "16.13.1",
"react-dom": "^16.13.1",
"react-native": "0.63.2",
"enzyme": "^3.11.0",
"react-test-renderer": "16.13.1"

Machine

Node -v `15.11.0`
NPM -v `7.6.1`

Adapter

  • enzyme-adapter-react-16
  • enzyme-adapter-react-16.3
  • enzyme-adapter-react-16.2
  • enzyme-adapter-react-16.1
  • enzyme-adapter-react-15
  • enzyme-adapter-react-15.4
  • enzyme-adapter-react-14
  • enzyme-adapter-react-13
  • enzyme-adapter-react-helper
  • others ( )
@ljharb
Copy link
Member

ljharb commented Apr 7, 2021

Your lockfile seems to suggest it’s installing react-dom 16.14 somewhere, which would require react 16.14.

You can either update both react and react-dom to 16.14, or you can downgrade react-dom to 16.13. Try installing react, react-dom, and the enzyme adapter all in the same install command.

@TommyLeong
Copy link
Author

@ljharb your suggestion helps to install enzyme-adapter-react-16 successfully.. but I realized after removing the file package-lock.json and again try to reinstall via npm install

At the same time, if I try to install other package (eg, npm i react-native-config) I get other issue as follow

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@"16.14.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.1" from [email protected]
npm ERR! node_modules/react-native-windows
npm ERR!   peer react-native-windows@">=0.61" from [email protected]
npm ERR!   node_modules/react-native-config
npm ERR!     react-native-config@"*" 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.

In short, switching react and react-dom to version 16.14.0 resolved my installation but raise other issues.

@ljharb
Copy link
Member

ljharb commented Apr 7, 2021

That means that version of react-native-windows requires react 17, which means it's incompatible with react 16 and can't be used. You'll either have to remove it, or downgrade it to one that supports react 16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants