16

While installing the dependencies for my project using npm install, I receive the following error that I don't know how to interpret:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: soft-ui-dashboard-pro-react@3.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@"^0.14.9 || ^15.3.0 || ^16.0.0" from react-quill@1.3.5
npm ERR! node_modules/react-quill
npm ERR!   react-quill@"1.3.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 /Users/amin/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/amin/.npm/_logs/2022-03-23T05_47_43_419Z-debug-0.log

These are the dependencies in package.json:

  "dependencies": {
    "@asseinfo/react-kanban": "2.2.0",
    "@emotion/cache": "11.7.1",
    "@emotion/react": "11.8.1",
    "@emotion/styled": "11.8.1",
    "@fullcalendar/daygrid": "5.10.1",
    "@fullcalendar/interaction": "5.10.1",
    "@fullcalendar/react": "5.10.1",
    "@fullcalendar/timegrid": "5.10.1",
    "@mui/icons-material": "5.4.2",
    "@mui/material": "5.4.3",
    "@mui/styled-engine": "5.4.2",
    "@pathofdev/react-tag-input": "1.0.7",
    "@react-leaflet/core": "1.1.1",
    "@testing-library/jest-dom": "5.16.2",
    "@testing-library/react": "12.1.3",
    "@testing-library/user-event": "13.5.0",
    "@three-ts/orbit-controls": "1.4.7",
    "chart.js": "3.4.1",
    "chroma-js": "2.4.2",
    "dropzone": "5.9.3",
    "flatpickr": "4.6.9",
    "formik": "2.2.9",
    "html-react-parser": "1.4.8",
    "leaflet": "1.7.1",
    "prop-types": "15.8.1",
    "react": "17.0.2",
    "react-chartjs-2": "3.0.4",
    "react-circular-slider-svg": "0.1.5",
    "react-countup": "6.1.1",
    "react-dom": "17.0.2",
    "react-flatpickr": "3.10.7",
    "react-github-btn": "1.2.1",
    "react-images-viewer": "1.7.1",
    "react-leaflet": "3.2.5",
    "react-quill": "1.3.5",
    "react-router-dom": "6.2.1",
    "react-scripts": "5.0.0",
    "react-select": "5.2.2",
    "react-table": "7.7.0",
    "stylis": "4.0.13",
    "stylis-plugin-rtl": "2.1.1",
    "sweetalert2": "11.4.4",
    "three": "0.121.1",
    "uuid": "8.3.2",
    "vanilla-tilt": "1.7.2",
    "web-vitals": "2.1.4",
    "yup": "0.32.11"
  },
Lin Du
  • 88,126
  • 95
  • 281
  • 483
aminrd
  • 4,300
  • 4
  • 23
  • 45

8 Answers8

28

It means you have dependency conflicts. So try running the following options one by one.

1. Remove node_modules and package-lock.json and then run

 npm install

2. Or try clearing out npm cache

npm cache clean --force

3. Or run command with --legacy-peer-deps option

npm install --legacy-peer-deps

4. Or run command with --force option

npm install --force
Surjeet Bhadauriya
  • 6,755
  • 3
  • 34
  • 52
24
  1. Remove node_modules

    rm -rf node_modules
    
  2. Set this

    npm config set legacy-peer-deps true
    
  3. Install npm

    npm install
    
vimuth
  • 5,064
  • 33
  • 79
  • 116
Uzma
  • 299
  • 2
  • 5
  • This actually should be the accepted answer! Thanks – AlexioVay Jan 25 '23 at 00:27
  • this one fix the problem. – Ranjithkumar Apr 25 '23 at 07:57
  • what does this actually do? – Gav Hern May 22 '23 at 19:59
  • Might be wrong but I don't think this should be the accepted answer as it does not go to the root of the problem and is misleading. By using legacy-peer-deps we might break something https://stackoverflow.com/questions/66239691/what-does-npm-install-legacy-peer-deps-do-exactly-when-is-it-recommended-wh – DanielPanic Jun 05 '23 at 13:42
  • If you want to set this npm config just for a specific project, navigate to its root and `npm config set legacy-peer-deps true --global false` – Jimmy Jun 06 '23 at 15:52
3

None of the above helped me. What helped me is, I switched to sass instead of node-sass and react 16, instead of react 17. Since node-sass is deprecated so use sass instead.(npm install sass) This work for me. Hurrey.

Tarun Kumar
  • 89
  • 1
  • 9
0

Follow below steps :

  1. Remove node_modules
  2. Remove package-lock.json
  3. Run npm install --force
sweetnandha cse
  • 705
  • 7
  • 16
0

One simple line

rm -f -- package-lock.json && rm -rf node_modules && npm i --legacy-peer-deps
Matt
  • 33,328
  • 25
  • 83
  • 97
0

Please be careful to run the npm install <package> with --force, or --legacy-peer-deps option, it will cause potentially broken. Instead, we should fix the version compatibility issues between dependent packages.

The warning means the react-quill@1.3.5 package demands react as its peer dependency with compatible versions. How do we know what versions are compatible?

Below command will check the peerDependencies field in the package.json file.

$ npm view react-quill@1.3.5 peerDependencies
{ react: '^0.14.9 || ^15.3.0 || ^16.0.0' }

As you can see, the compatible React versions are: '^0.14.9 || ^15.3.0 || ^16.0.0'. But you have installed react: 17.0.2 in your project. That's why you got the warning.

Two safe solutions:

  • Downgrading the react package to those compatible versions, you can use the last version of 16.x. Which you can find by running the below command:
$ npm view react@16 version
react@16.0.0 '16.0.0'
react@16.1.0 '16.1.0'
react@16.1.1 '16.1.1'
react@16.2.0 '16.2.0'
react@16.3.0 '16.3.0'
react@16.3.1 '16.3.1'
react@16.3.2 '16.3.2'
react@16.4.0 '16.4.0'
react@16.4.1 '16.4.1'
react@16.4.2 '16.4.2'
react@16.5.0 '16.5.0'
react@16.5.1 '16.5.1'
react@16.5.2 '16.5.2'
react@16.6.0 '16.6.0'
react@16.6.1 '16.6.1'
react@16.6.2 '16.6.2'
react@16.6.3 '16.6.3'
react@16.7.0 '16.7.0'
react@16.8.0 '16.8.0'
react@16.8.1 '16.8.1'
react@16.8.2 '16.8.2'
react@16.8.3 '16.8.3'
react@16.8.4 '16.8.4'
react@16.8.5 '16.8.5'
react@16.8.6 '16.8.6'
react@16.9.0 '16.9.0'
react@16.10.0 '16.10.0'
react@16.10.1 '16.10.1'
react@16.10.2 '16.10.2'
react@16.11.0 '16.11.0'
react@16.12.0 '16.12.0'
react@16.13.0 '16.13.0'
react@16.13.1 '16.13.1'
react@16.14.0 '16.14.0'
$ npm install react@^16.14.0 react-dom@^16.14.0 -S
  • Use react-quill@2, which is compatible with react v17, see the peer dependencies:
$ npm view react-quill@2 peerDependencies
{ react: '^16 || ^17 || ^18', 'react-dom': '^16 || ^17 || ^18' }
Lin Du
  • 88,126
  • 95
  • 281
  • 483
0

first you have to run this command in terminal

npm config set legacy-peer-deps true

and then try install package it should solve the problem

  • This answer is the same as (or very similar to) [this one](https://stackoverflow.com/a/72897609/). It would be better to upvote that answer instead of posting it again. Invest some time in the site and you will gain sufficient [privileges](//stackoverflow.com/privileges) to upvote answers that helped you. – LW001 Aug 09 '23 at 20:58
0

I had to uninstall the package that was causing problems, install the new one, and install the package that I uninstalled before.

overheated
  • 310
  • 4
  • 11