首页 > 解决方案 > React-spring with gatsby - 安装时出错

问题描述

我正在尝试将 react-spring 添加到 gatsby(Gatsby 3.13.0,React 17.0.2)。当我输入“npm i react-spring”时,会出现这样的错误:

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! 

我尝试了 --force 或 --legacy-peer-deps,但没有帮助。是 React 17 还是 Gatsby 的问题?

标签: reactjsnpmreact-spring

解决方案


我会安装您正在使用的特定目标。例如,由于您使用的是gatsby我假设您希望@react-spring/web这应该解决问题npm@7


推荐阅读