处理有关 Bootstrap 的 'unmet peer dependency' 未在 Angular 中使用时的 NPM 警告
Handle NPM warning about Bootstrap's 'unmet peer dependency' when they are not used in Angular
我在我的网络项目中使用 Angular 5.2.0 和 Bootstrap 4。我通过 npm i bootstrap --save
安装了 bootstrap 4,它告诉我未满足的对等依赖项:
npm WARN bootstrap@4.0.0 requires a peer of jquery@>=3.0.0 but none was installed.
npm WARN bootstrap@4.0.0 requires a peer of popper.js@^1.11.0 but none was installed.
当然,Bootstrap的JS就依赖这些对等依赖。到目前为止,一切如常。
问题是:我不使用任何 Bootstraps JS。我正在使用 ng-bootstrap,这是为 Angular.
重写的 Bootstrap 组件
这个警告让我很烦,因为它真的不是什么东西,当我不使用它时(这个项目中没有其他人应该 - 在尝试使用 Bootstrap 时出现错误原生组件非常好)。干净的代码和依赖项不应输出任何警告。
为了摆脱这个警告,我尝试了不同的方法:
- 找到一个只包含 Bootstrap 的 SCSS 的 npm 包。 There is at least one 但它仍然使用 Bootstrap 的版本 3 . 此外,没有办法知道这些包何时更新,所以我更喜欢使用原始的
bootstrap
包。
- 只安装依赖项而不使用它们。这会导致
package.json
中的依赖项未被使用 - 并且应该(恕我直言)在干净的代码环境。
- 消除来自yarn/npm的警告(我最近切换到yarn,但错误类似)。可能不是一个好主意,警告通常很有用...似乎还有consensus,那个人不应该能够关闭特定的警告。我有点同意。
- 忽略它们。对我来说不是一个选择——如上所述,一个干净的构建过程不应该 return 警告。
所以:有什么方法可以干净地处理这些对等依赖警告吗?
遗憾的是,真正的答案是我们需要忽略警告。
ng-bootstrap
的创建者在 . They also mention that you shouldn't install the jquery
or popper.js
dependencies due to potential conflicts (per the setup docs 中明确指出,由于技术原因,警告是我们唯一的选择。
我在我的网络项目中使用 Angular 5.2.0 和 Bootstrap 4。我通过 npm i bootstrap --save
安装了 bootstrap 4,它告诉我未满足的对等依赖项:
npm WARN bootstrap@4.0.0 requires a peer of jquery@>=3.0.0 but none was installed.
npm WARN bootstrap@4.0.0 requires a peer of popper.js@^1.11.0 but none was installed.
当然,Bootstrap的JS就依赖这些对等依赖。到目前为止,一切如常。
问题是:我不使用任何 Bootstraps JS。我正在使用 ng-bootstrap,这是为 Angular.
重写的 Bootstrap 组件这个警告让我很烦,因为它真的不是什么东西,当我不使用它时(这个项目中没有其他人应该 - 在尝试使用 Bootstrap 时出现错误原生组件非常好)。干净的代码和依赖项不应输出任何警告。
为了摆脱这个警告,我尝试了不同的方法:
- 找到一个只包含 Bootstrap 的 SCSS 的 npm 包。 There is at least one 但它仍然使用 Bootstrap 的版本 3 . 此外,没有办法知道这些包何时更新,所以我更喜欢使用原始的
bootstrap
包。 - 只安装依赖项而不使用它们。这会导致
package.json
中的依赖项未被使用 - 并且应该(恕我直言)在干净的代码环境。 - 消除来自yarn/npm的警告(我最近切换到yarn,但错误类似)。可能不是一个好主意,警告通常很有用...似乎还有consensus,那个人不应该能够关闭特定的警告。我有点同意。
- 忽略它们。对我来说不是一个选择——如上所述,一个干净的构建过程不应该 return 警告。
所以:有什么方法可以干净地处理这些对等依赖警告吗?
遗憾的是,真正的答案是我们需要忽略警告。
ng-bootstrap
的创建者在 jquery
or popper.js
dependencies due to potential conflicts (per the setup docs 中明确指出,由于技术原因,警告是我们唯一的选择。