纱线警告“ > bootstrap@4.x.x” 具有未满足的对等依赖性 "jquery@1.9.1 - 3"

yarn warning " > bootstrap@4.x.x" has unmet peer dependency "jquery@1.9.1 - 3"

当我们 运行 yarn 在没有 node_modules 目录的项目中时,我们在依赖项安装期间收到以下警告消息:

warning " > bootstrap@4.4.1" has unmet peer dependency "jquery@1.9.1 - 3".
warning " > bootstrap@4.4.1" has unmet peer dependency "popper.js@^1.16.0".

但是,bootstrapreact-bootstrap 似乎在没有采取任何措施来修复这 2 个警告的情况下工作正常。 package.json 也不包含这 2 个包的条目。

问题:为什么 Bootstrap 和相关文件在没有满足对等依赖性的情况下似乎继续工作?

yarnnpm 的重点不就是管理这些依赖关系吗?

解决这些警告的正确方法是什么?


部分packages.json

{
  ...

  "dependencies": {
    "bootstrap": "^4.4.1",
    "react-bootstrap": "^1.0.0",

    ...
  }
}

jquerypopper.js 被 Bootstrap 用于其 Javascript 组件(下拉菜单、模式等)。但是:如果您只使用 CSS 部分 - 您不需要这些。这可能就是为什么它们被列为 "peer-dependencies".

有一个 Pull Request 可以使这些警告静音。毕竟它们只是警告。

react-bootstrap 不是 need/replaces jquery 但它在另一个版本 (@popperjs/core) 中使用 popper 来放置工具提示。这就是为什么一切正常的原因 - 尽管 Bootstrap 缺少一些 "peer-dependencies"。像 (react|vue|ng)-bootstrap 这样的库通常只使用 Bootstrap 的 CSS 部分并完全重写 Javascript 部分。

What is the proper way to resolve these warnings?

据我了解:您必须将它们作为依赖项添加到您的项目中 - 即使您实际上并不需要它们。或者...忽略警告。