Enzyme with react 17.0.1 - javascript

I'm tryng to install this enzyme adapter for react17 and during the install throw me this error:
$ npm install --save-dev #wojtekmaj/enzyme-adapter-react-17
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: react#17.0.1
npm WARN node_modules/react
npm WARN peer react#"^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" from mini-create-react-context#0.4.1npm WARN node_modules/mini-create-react-context
npm WARN mini-create-react-context#"^0.4.0" from react-router#5.2.0
npm WARN node_modules/react-router
npm WARN 4 more (react-router, react-router-dom, the root project, #wojtekmaj/enzyme-adapter-react-17)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react#"0.13.x || 0.14.x || ^15.0.0-0 || ^16.0.0-0" from enzyme-adapter-utils#1.14.0
npm ERR! peer react#"^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" from mini-create-react-context#0.4.1npm ERR! node_modules/mini-create-react-context
npm ERR! mini-create-react-context#"^0.4.0" from react-router#5.2.0
npm ERR! node_modules/react-router
npm ERR! react-router#"5.2.0" from react-router-dom#5.2.0
npm ERR! node_modules/react-router-dom
npm ERR! react-router-dom#"^5.2.0" from the root project
npm ERR! peer react#">=15" from react-router#5.2.0
npm ERR! node_modules/react-router
npm ERR! react-router#"5.2.0" from react-router-dom#5.2.0npm ERR! node_modules/react-router-dom
npm ERR! react-router-dom#"^5.2.0" from the root project
npm ERR! 3 more (react-router-dom, the root project, #wojtekmaj/enzyme-adapter-react-17)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^0.14 || ^15.0.0 || ^16.0.0-alpha" from airbnb-prop-types#2.16.0
npm ERR! node_modules/enzyme-adapter-utils/node_modules/airbnb-prop-types
npm ERR! airbnb-prop-types#"^2.16.0" from enzyme-adapter-utils#1.14.0
npm ERR! node_modules/enzyme-adapter-utils
npm ERR! enzyme-adapter-utils#"^1.14.0" from #wojtekmaj/enzyme-adapter-react-17#0.4.1
npm ERR! node_modules/#wojtekmaj/enzyme-adapter-react-17
npm ERR! dev #wojtekmaj/enzyme-adapter-react-17#"*" 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 C:\Users\dittl\AppData\Local\npm-cache\eresolve-report.txt for a full report.
It's this a problem beacause I'm using react 17.0.1? Because in the past I work with the enzyme adapter in react 17 and works perfect.

in the link you sent, the docs say to use the legacy-peer-deps flag.
Note for npm v7 users
enzyme's dependencies have not yet been updated to declare React 17 in peerDependencies. You need to add --legacy-peer-deps to the install command for it to work correctly.
I would suggest using that in your command as such
npm install --save-dev #wojtekmaj/enzyme-adapter-react-17 --legacy-peer-deps

Related

heroku build failed on deployment

I am trying to host my React application on heroku but I keep getting the following errors:
-----> Installing dependencies
Installing node modules
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-credit-card-input#1.1.5
npm ERR! Found: react#17.0.2
npm ERR! node_modules/react
npm ERR! react#"^17.0.2" from the root project
npm ERR! peer react#">=16.8.0" from #emotion/react#11.7.1
npm ERR! node_modules/#emotion/react
npm ERR! #emotion/react#"^11.7.1" from the root project
npm ERR! peer #emotion/react#"^11.0.0-rc.0" from #emotion/styled#11.6.0
npm ERR! node_modules/#emotion/styled
npm ERR! #emotion/styled#"^11.6.0" from the root project
npm ERR! 3 more (#mui/material, #mui/styled-engine, #mui/system)
npm ERR! 3 more (#mui/material, #mui/styled-engine, #mui/system)
npm ERR! 31 more (#emotion/styled, #mui/base, #mui/icons-material, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0" from react-credit-card-input#1.1.5
npm ERR! node_modules/react-credit-card-input
npm ERR! react-credit-card-input#"^1.1.5" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react#16.14.0
npm ERR! node_modules/react
npm ERR! peer react#"^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0" from react-credit-card-input#1.1.5
npm ERR! node_modules/react-credit-card-input
npm ERR! react-credit-card-input#"^1.1.5" 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 /tmp/npmcache.GoZcZ/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.GoZcZ/_logs/2022-06-27T11_25_24_489Z-debug-0.log
I have tried to do both --legacy-peer-deps and npm install --force but my build keeps getting failed. Is there a way to fix this recurrent problem.
I had to update the peer dependency for credit-card-input library in the package-lock.json file to be compatible with my version of react and this solves my problem. I'm not sure if this is the best way but it solves the issue for me.

When I try to install material ui icon dependency face this error

npm i #material-ui/icons
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: my-app#0.1.0
npm ERR! Found: react#18.1.0
npm ERR! node_modules/react
npm ERR! peer react#"^18.0.0" from #testing-library/react#13.1.1
npm ERR! node_modules/#testing-library/react
npm ERR! #testing-library/react#"^13.1.1" from the root project
npm ERR! peer react#"^18.1.0" from react-dom#18.1.0
npm ERR! node_modules/react-dom
npm ERR! peer react-dom#"^18.0.0" from #testing-library/react#13.1.1
npm ERR! node_modules/#testing-library/react
npm ERR! #testing-library/react#"^13.1.1" from the root project
npm ERR! 1 more (react-scripts)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! #material-ui/icons#"*" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react#17.0.2
npm ERR! node_modules/react
npm ERR! peer react#"^16.8.0 || ^17.0.0" from #material-ui/icons#4.11.3
npm ERR! node_modules/#material-ui/icons
npm ERR! #material-ui/icons#"*" 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 C:\Users\Vikash\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:npm ERR! C:\Users\Vikash\AppData\Local\npm-cache\_logs\2022-05-03T21_09_36_618Z-debug-0.log
PS C:\Users\Vikash\Desktop\personal portfolio\my-app>
Use the below command to install MUI v5 with React 18.1.0
npm install #mui/material #emotion/react #emotion/styled
Follow MUI Documentation
I tried the below
npm i #material-ui/icons --legacy-peer-deps
Then it happens new errors, I tried to upgrade "#material-ui/core": "^4.12.4" and it works.

How Can I Resolve this error for Installing npm install --save react-html-table-to-excel this packages

I am getting this error for installing "npm install --save react-html-table-to-excel " this package.
PS C:\Users\Dev03\OneDrive\Desktop\Project\usermanagement> npm install react-html-table-to-excel
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! While resolving: usermanagement#0.1.0
npm ERR! Found: react#17.0.2
npm ERR! node_modules/react
npm ERR! react#"^17.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^15.x.x" from react-html-table-to-excel#2.0.0
npm ERR! node_modules/react-html-table-to-excel
npm ERR! react-html-table-to-excel#"*" 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 C:\Users\Dev03\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Dev03\AppData\Local\npm-cache_logs\2021-09-27T11_45_28_139Z-debug.log
Try this:
npm install --save react-html-table-to-excel --legacy-peer-deps
react-html-table-to-excel requires react 15.
https://github.com/zsusac/ReactHTMLTableToExcel/blob/master/package.json#L42
Either you will have to downgrade to react 15, or you could try to force the installation with the legacy-peer-deps flag like this:
npm install react-html-table-to-excel --legacy-peer-deps

Is using '--force' or '--legacy-peer-deps' would harm in long run?

I am currently working on a react-native project and want to install native-base library but getting the following error ...
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: demo#0.0.1
npm ERR! Found: react#17.0.2
npm ERR! node_modules/react
npm ERR! react#"^17.0.1" from the root project
npm ERR! peer react#"*" from native-base#3.0.6
npm ERR! node_modules/native-base
npm ERR! native-base#"3.0.6" from the root project
npm ERR! 1 more (react-dom)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"17.0.1" from react-native#0.64.2
npm ERR! node_modules/react-native
PS C:\Users\Bishal Ghosh\Desktop\React-Native\demo> npm install native-base --save
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: demo#0.0.1
npm ERR! Found: react#17.0.2
npm ERR! node_modules/react
npm ERR! react#"^17.0.1" from the root project
npm ERR! peer react#"*" from native-base#3.0.6
npm ERR! node_modules/native-base
npm ERR! native-base#"*" from the root project
npm ERR! 1 more (react-dom)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"17.0.1" from react-native#0.64.2
npm ERR! node_modules/react-native
npm ERR! react-native#"^0.64.2" from the root project
npm ERR! peer react-native#"*" from native-base#3.0.6
npm ERR! node_modules/native-base
npm ERR! native-base#"*" 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 C:\Users\Bishal Ghosh\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Bishal Ghosh\AppData\Local\npm-cache\_logs\2021-08-02T06_48_53_257Z-debug.log
I tried solving the issue by removing my node_modules folder but didn't work. Then, I installed using --legacy-peer-deps, it gets installed. So, now I would like to know will it run in long-run if I install my dependencies using those flags??
I don't think it would harm but I can't tell you that as a fact.
What I can do is to tell how I solved similar issue I had.
I assume that you are using npm version 7.X.X (you can check it with npm --version
If that indeed the case this error will be shown almost on every dependency you'll try to install so what I did was to downgrade back to npm 6.
To do that all you need to do is run the following command in your command line:
npm install -g npm#6.14.13

issue installing npm package, react-circular-progressbar

When I install react-circular-progressbar into my react projects it show an error why?
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: nadeems-portfolio#0.1.0
npm ERR! Found: react#17.0.1
npm ERR! node_modules/react
npm ERR! react#"^17.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^0.14.0 || ^15.0.0 || ^16.0.0" from react-circular-progressbar#2.0.3
npm ERR! node_modules/react-circular-progressbar
npm ERR! react-circular-progressbar#"*" 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 /home/nadeem/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/nadeem/.npm/_logs/2020-12-05T09_58_59_238Z-deb
This is because one of the depencies can not be resolved combined with your current dependencies.
The following part indicates that ciruclar-progressbar (version 2.0.3) requires react 15 or 16 as a peer dependency, and you are using a newer version in your dependency list.
Could not resolve dependency: peer react#"^0.14.0 || ^15.0.0 || ^16.0.0" from react-circular-progressbar#2.0.3
There are a few solutions;
Downgrade the package that doesn't fit in the constraints of the package that you want to install
Look for a version of the package that you are trying to install that has updated their peer dependencies to include react 17
use npm install <package-name> --force to ignore it (really not recommended, unless you have manually verified there are no incompatibilities)
use npm install <package-name> --legacy-peer-deps.
The first two options are deduced from the error you have given. Whereas the last two options are provided in the error itself.

Categories