npm 安装时ReactSpring错误

uklbhaso  于 2023-01-13  发布在  React
关注(0)|答案(3)|浏览(248)

你好,我有这个问题,如果我想安装react-spring到我的react项目它只是弹出一堆依赖错误和警告,我不知道该怎么办。我试图检查react-spring的文档,但我找不到任何东西。我检查了几页stackoverflow这里,我仍然没有找到任何有用的。有人能帮助吗?

npm WARN ERESOLVE overriding peer dependency
npm WARN Found: react@17.0.2
npm WARN node_modules/react-spring/node_modules/react
npm WARN   peer react@">=16.8" from @react-spring/konva@9.0.0
npm WARN   node_modules/react-spring/node_modules/@react-spring/konva
npm WARN     @react-spring/konva@"^9.0.0" from react-spring@9.0.0
npm WARN     node_modules/react-spring
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"16.8.x" from react-konva@16.8.6
npm WARN node_modules/react-spring/node_modules/react-konva
npm WARN   peer react-konva@">=16.8" from @react-spring/konva@9.0.0
npm WARN   node_modules/react-spring/node_modules/@react-spring/konva
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: react@17.0.2
npm WARN node_modules/react-spring/node_modules/react
npm WARN   peer react@">=16.8" from @react-spring/konva@9.0.0
npm WARN   node_modules/react-spring/node_modules/@react-spring/konva
npm WARN     @react-spring/konva@"^9.0.0" from react-spring@9.0.0
npm WARN     node_modules/react-spring
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"^16.0.0" from react-dom@16.8.6
npm WARN node_modules/react-spring/node_modules/react-dom
npm WARN   peer react-dom@"16.8.x" from react-konva@16.8.6
npm WARN   node_modules/react-spring/node_modules/react-konva
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: konva@7.2.5
npm WARN node_modules/konva
npm WARN   peer konva@">=2.6" from @react-spring/konva@9.0.0
npm WARN   node_modules/react-spring/node_modules/@react-spring/konva
npm WARN     @react-spring/konva@"^9.0.0" from react-spring@9.0.0
npm WARN     node_modules/react-spring
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer konva@"^3.2.3" from react-konva@16.8.6
npm WARN node_modules/react-spring/node_modules/react-konva
npm WARN   peer react-konva@">=16.8" from @react-spring/konva@9.0.0
npm WARN   node_modules/react-spring/node_modules/@react-spring/konva
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: react-spring@9.0.0
npm WARN Found: react-dom@17.0.2
npm WARN node_modules/react-dom
npm WARN   peerOptional react-dom@">=17.0" from @react-three/fiber@6.0.1
npm WARN   node_modules/@react-three/fiber
npm WARN     peer @react-three/fiber@">=6.0" from @react-spring/three@9.0.0
npm WARN     node_modules/@react-spring/three
npm WARN
npm WARN Could not resolve dependency:
npm WARN peerOptional react-dom@">=17.0" from @react-three/fiber@6.0.1
npm WARN node_modules/@react-three/fiber
npm WARN   peer @react-three/fiber@">=6.0" from @react-spring/three@9.0.0
npm WARN   node_modules/@react-spring/three
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR!   peer react@"*" from @testing-library/react@11.2.5
npm ERR!   node_modules/@testing-library/react
npm ERR!     @testing-library/react@"^11.2.5" from the root project
npm ERR!   peer react@"17.0.1" from react-dom@17.0.1
npm ERR!   node_modules/react-dom
npm ERR!     peer react-dom@"*" from @testing-library/react@11.2.5
npm ERR!     node_modules/@testing-library/react
npm ERR!       @testing-library/react@"^11.2.5" from the root project
npm ERR!     peer react-dom@">=16.0.0" from react-visibility-sensor@5.1.1
npm ERR!     node_modules/react-visibility-sensor
npm ERR!       react-visibility-sensor@"^5.1.1" from the root project
npm ERR!     1 more (the root project)
npm ERR!   4 more (react-scripts, react-visibility-sensor, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^17.0.2" from react-reconciler@0.26.2
npm ERR! node_modules/@react-three/fiber/node_modules/react-reconciler
npm ERR!   react-reconciler@"^0.26.2" from @react-three/fiber@6.0.1
npm ERR!   node_modules/@react-three/fiber
npm ERR!     peer @react-three/fiber@">=6.0" from @react-spring/three@9.0.0
npm ERR!     node_modules/@react-spring/three
npm ERR!       @react-spring/three@"^9.0.0" from react-spring@9.0.0
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!
npm ERR! See C:\...\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
gzszwxb4

gzszwxb41#

问题是npm 7需要安装peer deps。这是npm 7的一个特性,而不是一个bug。react-spring是库的全局包,因此包含了我们所有的目标。除非你真的在做一个需要zDogkonva等的应用,否则我会安装你想要的特定目标。
npm install @react-spring/web/* 可以替换为我们支持的任何目标,有关详细信息,请参阅文档

nhhxz33t

nhhxz33t2#

有同样的问题,this建议修复了安装错误。但仍然没有尝试处理它。基本上,我们应该添加

"peerDependencies": {
  "react-spring": "^8.x"
}

到package.json文件

9bfwbjaz

9bfwbjaz3#

我在使用React 17.0.2时遇到了同样的问题,但成功运行了npm install -g react-spring,然后没有错误,但仍然有很多警告

相关问题