0

我在 2 小时前开始学习 React 和 FluentUI。我正在尝试互联网上提供的各种教程,但不能仅仅通过 FluentUI 包安装步骤。我收到以下错误:

npm i @fluentui/react
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: fluent-ui-todo-app@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 <17.0.0" from @fluentui/react@7.153.4
npm ERR! node_modules/@fluentui/react
npm ERR!   @fluentui/react@"*" 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 ------\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     ------\Local\npm-cache\_logs\2020-12-10T12_41_32_759Z-debug.log

我尝试卸载 react 并安装 react@16.14.0,但这无济于事,因为还有其他依赖于 react@17.0.1 的包。我能做些什么?

npm install react@16.14.0
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: react@16.14.0
npm ERR! node_modules/react
npm ERR!   react@"16.14.0" from the root project
npm ERR!   peer react@"*" from @testing-library/react@11.2.2
npm ERR!   node_modules/@testing-library/react
npm ERR!     @testing-library/react@"^11.2.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
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.2
npm ERR!   node_modules/@testing-library/react
npm ERR!     @testing-library/react@"^11.2.2" from the root project
npm ERR!   react-dom@"^17.0.1" 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!
4

1 回答 1

0

我在尝试安装 fluentui 包时遇到了同样的问题,经过一些试错循环后,我发现它适用于我的 react 版本 16.8,我不得不更改以下包:

"@types/react": "16.8",
"@types/react-dom": "16.8",
"react": "16.8",
"react-dom": "16.8"

希望这会有所帮助,干杯;)

于 2020-12-27T22:28:54.667 回答