当我在当前的React项目上运行npm i时,收到关于react peerDependency的以下警告:

npm WARN react-tap-event-plugin@3.0.3 requires a peer of react@^16.0.0-0 < 16.4.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-paginate@4.4.4 requires a peer of react@^15.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN formsy-react@0.19.5 requires a peer of react@^0.14.0 || ^15.0.0 but none is installed. You must install peer dependencies yourself.

在我的package.json中,我正在使用最新版本的react:
"react": "^16.7.0"

我是node和npm的新手。我想知道安装npm peerDependencies的良好做法是什么:

1.)如果在package.json中已经指定了更新版本,可以忽略较低版本的警告。

2.)按照
https://lexi-lambda.github.io/blog/2016/08/24/understanding-the-npm-dependency-model/

https://github.com/npm/npm/issues/6565

npm提供了依赖隔离,并且peerDepencies需要手动安装,因此我应该安装所有3个版本的react,但是我担心这会破坏import语句。

3.)如果以上两个都不是,我应该在package.json中使用哪个版本。
P.S.我的package.json中还有更多依赖项,可能也需要最新版本。

最佳答案

进一步讲Danyal的答案,您可以升级Forms-react并删除react-tap-event-plugin:

  • 将formy-react更新为最新版本 :(在撰写本文时为1.1.5),此软件包的最新版本支持react ^ 16。
  • react-tap-event-plugin 支持React版本直至16.4。您可以在此处选择以下几种方式:
  • 降级 react :降级到16.4将删除所有警告,但会限制您将来升级
  • 的能力
  • 删除react-tap-event-plugin :根据文档https://www.npmjs.com/package/react-tap-event-plugin。实际上,由于对更高版本的浏览器进行了修复,因此不建议使用此模块。检查blog post以获取信息。
  • Fork react-tap-event-plugin :我自己不会这样做,但是您可以派发插件并使用更新的react peerDependency自己发布。
  • 10-06 04:20
    查看更多