react-helmet-async 包的 npm peer 依赖项在使用 React 17 时出错

问题描述

对于使用 create-react-app 引导的 React 17 项目,我想使用 react-helmet-async 包。 此项目具有以下对等依赖项,位于 package.json 文件中:

  "peerDependencies": {
    "react": "^16.6.0","react-dom": "^16.6.0"
  },

尝试安装软件包时,出现以下错误

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: project@1.0.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.6.0" from react-helmet-async@1.0.7
npm ERR! node_modules/react-helmet-async
npm ERR!   react-helmet-async@"^1.0.7" 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/bas/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/bas/.npm/_logs/2021-02-11T13_55_56_813Z-debug.log

据我所知,react-helmet-async 包需要 React ^16.6.0 用于使用此包的项目。我可以使用 --force 选项来消除错误,但是当我尝试执行 npm update 时它会不断重复发生。

我尝试在我的 package.json添加分辨率,试图强制包使用我正在使用的 React 版本。在运行 npm installnpm update 之前,我运行了 npx npm-force-resolutions

  "resolutions": {
    "react-helmet-async/react": "^17.0.1"
  }

这很不幸没有奏效。有没有什么方法可以在不降级到 React 16 的情况下继续使用这个包而不会在我的控制台中收到错误消息?另外,我是否误解了对等依赖项?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)