I'm trying to add react-spring to gatsby (Gatsby 3.13.0, React 17.0.2). When I type "npm i react-spring" such an error appears:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
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 || ^17.0.0" from @react-spring/core@9.2.4
npm ERR! node_modules/@react-spring/core
npm ERR! @react-spring/core@"~9.2.0" from react-spring@9.2.4
npm ERR! node_modules/react-spring
npm ERR! react-spring@"*" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.0.0" from react-reconciler@0.20.4
npm ERR! node_modules/react-zdog/node_modules/react-reconciler
npm ERR! react-reconciler@"^0.20.4" from react-zdog@1.0.11
npm ERR! node_modules/react-zdog
npm ERR! peer react-zdog@">=1.0" from @react-spring/zdog@9.2.4
npm ERR! node_modules/@react-spring/zdog
npm ERR! @react-spring/zdog@"~9.2.0" from react-spring@9.2.4
npm ERR! node_modules/react-spring
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!
I tried --force, or --legacy-peer-deps, but it doesn't help. Is it a problem with React 17 or Gatsby?
I would install the specific target you are using. For example, since you're using gatsby
I assume you'll want @react-spring/web
this should resolve the issue with npm@7
.