No se puede resolver el árbol de dependencia Reactjs

6 minutos de lectura

Estoy tratando de instalar react-tinder-card en mi proyecto actual. Así que estoy tratando de instalar react-tinder-card pero después de usar el comando

npm install –save react-tinder-card

Todo lo que puedo ver en mi consola es:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: tinder-clone@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@"^16.8.0" from react-tinder-card@1.3.1
npm ERR! node_modules/react-tinder-card
npm ERR!   react-tinder-card@"*" 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/nero/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/nero/.npm/_logs/2020-11-06T16_36_39_957Z-debug.log

Cuando abrí el archivo debug.log, encontré esto:

0 CLI detallado [
0 verbose cli   '/usr/bin/node',
0 verbose cli   '/usr/bin/npm',
0 verbose cli   'install',
0 verbose cli   '--save',
0 verbose cli   'react-tinder-card'
0 verbose cli ]
1 información usando npm@7.0.3 2 información usando node@v15.0.1 3 sincronización config:load:defaults Completado en 3ms 4 sincronización config:load:file:/usr/lib/node_modules/npm/npmrc Completado en 0ms 5 sincronización config :load:builtin Completado en 1ms 6 tiempos config:load:cli Completado en 3ms 7 tiempos config:load:env Completado en 1ms 8 tiempos config:load:file:/home/nero/Documents/MERN/tinder-clone/.npmrc Completado en 1ms 9 sincronización config:load:project Completado en 2ms 10 sincronización config:load:file:/home/nero/.npmrc Completado en 0ms 11 sincronización config:load:user Completado en 0ms 12 sincronización config:load:file:/ usr/etc/npmrc Completado en 0ms 13 sincronización config:load:global Completado en 0ms 14 sincronización config:load:cafile Completado en 0ms 15 sincronización config:load:validate Completado en 0ms 16 sincronización config:load:setUserAgent Completado en 0ms 17 sincronización config:load:setEnvs Completado en 1ms 18 timing config:load Completado en 12ms 19 verbose npm-session b46c4469ef66a9f2 20 timing npm:load Completado en 19ms 21 timing arborist:ctor Completado en 0ms 22 tiempo idealTree:init Completado en 1413ms 23 tiempo idealTree:userRequests Completado en 3ms 24 silly idealTree buildDeps 25 silly fetch manifest react-tinder-card@* 26 http fetch GET 200 188ms (del caché) 27 Silly Fetch Manifest react@^17.0.1 28 timing arborist:ctor Completado en 0ms 29 http fetch GET 304 1196ms (del caché) 30 timing idealTree Completado en 2812ms 31 comando de temporización: instalación completada en 2815 ms 32 error de pila detallada: no se pudo resolver el árbol de dependencia 32 pila detallada en Arborist.[failPeerConflict] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1011:25) 32 pila detallada en Arborist.[loadPeerSet] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:991:36) 32 pilas detalladas en Async Arborist.[buildDepStep] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:760:11) 32 pila detallada en asíncrono Arborist.buildIdealTree (/usr/lib/node_modules/npm /node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:202:7) 32 pila detallada en async Promise.all (índice 1) 32 pila detallada en async Arborist.reify (/usr/lib/ node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:121:5) 32 pila detallada en instalación asíncrona (/usr/lib/node_modules/npm/lib/install.js:40:5) 33 verbose cwd /home/nero/Documents/MERN/tinder-clone 34 verbose Linux 5.4.0-52-generic 35 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "--save " "react-tinder-card" 36 verbose node v15.0.1 37 verbose npm v7.0.3 38 código de error ERESOLVE 39 error ERESOLVE no pudo resolver el árbol de dependencia 40 error 41 error Al resolver: [1mtinder-clone[22m@[1m0.1.0[22m
41 error Found: [1mreact[22m@[1m17.0.1[22m[2m[22m
41 error [2mnode_modules/react[22m
41 error   [1mreact[22m@"[1m^17.0.1[22m" from the root project
41 error
41 error Could not resolve dependency:
41 error [35mpeer[39m [1mreact[22m@"[1m^16.8.0[22m" from [1mreact-tinder-card[22m@[1m1.3.1[22m[2m[22m
41 error [2mnode_modules/react-tinder-card[22m
41 error   [1mreact-tinder-card[22m@"[1m*[22m" from the root project
41 error
41 error Fix the upstream dependency conflict, or retry
41 error this command with --force, or --legacy-peer-deps
41 error to accept an incorrect (and potentially broken) dependency resolution.
41 error
41 error See /home/nero/.npm/eresolve-report.txt for a full report.
42 verbose exit 1

I don’t understand what that means. Please help me find the solution.Any sort of help would be appreciated.
Thank you in advance.

  • Hi Sunil! I have just posted an answer to a similar question here:…. The core of the problem that you’re facing is exactly the same, only the details differ. This answer should guide you in the right direction.

    – Avius

    Nov 9, 2020 at 0:53

  • Thank @Avius for this.

    – Sunil Shah

    Nov 10, 2020 at 10:52

Vaibhav Dhawale's user avatar
Vaibhav Dhawale

$ npm install --save react-tinder-card --legacy-peer-deps

  • And what exactly will do this command? Please explain it for other users.

    – SwissCodeMen

    Dec 12, 2020 at 13:00

  • I have found @Arosha ‘s answer to be more helpful, the package will install with the –legacy flag, but the module doesn’t work. It’s easier to downgrade to npm 6

    – Luke Vanzweden

    Jun 5, 2021 at 15:28

  • Well, this command worked for me. But I had a question that is it a good practice, If not then what could be the alternatives to it?

    – Meet Bhalodiya

    May 16 at 4:54

  • Recently i had this problem and my solution was to update my node version from 14 to 16

    – Gabriel Rodrigues

    Jun 4 at 17:13

Mon's user avatar

This error comes from version 7.x of npm.

Please try again with the --legacy-peer-deps option.

What this error basically says is that react-tinder-card@1.3.1 in it’s peer dependencies has react@"^16.8.0". So it needs that version of react to function properly. On your tinder-clone@0.1.0 application you currently have react@17.0.1.

This problem can be solved manually by just installing version of react that react-tinder-card@1.3.1 needs which is react@"^16.8.0", so you need to downgrade your version to run the package.

The --legacy-peer-deps flag was introduced with v7 of npm as a way to bypass peerDependency auto-installation; it tells NPM to ignore peer deps and proceed with the installation anyway. This can cause some unwanted behavior and I would not suggest it.

Downgrade to npm v6. It should fix the issue.

npm install -g npm@6

This happens when you are trying to clone a project which is built a long time ago, and project dependencies have moved on to newer versions.

Just run below code. Works fine for me every time. You should also see this solution with the error.

 npm install --legacy-peer-deps

Tatyana Molchanova's user avatar
Tatyana Molchanova

The react-apollo package has been deprecated, and the functionality offered by each of the above packages can now be accessed from @apollo/client directly:

@apollo/react-hooks -> now available directly from @apollo/client
@apollo/react-components -> now available from @apollo/client/react/components
@apollo/react-hoc -> now available from @apollo/client/react/hoc
@apollo/react-ssr -> now available from @apollo/client/react/ssr
@apollo/react-testing -> now available from @apollo/client/testing

Larry Sankey's user avatar
Larry Sankey

I had the same error above. I installed npm v6.7. I reinstalled Netlify CMS and Gatsby:

npm install netlify-cms-app@2.9 gatsby-plugin-netlify-cms@^4.0.0

I don’t have anything under the static folder except a favicon.ico file. No admin folder and no .yml file.

¿Ha sido útil esta solución?