简体   繁体   English

NPM 警告:bootstrap@4.0.0 需要 popper.js 的对等体

[英]NPM WARN: bootstrap@4.0.0 requires a peer of popper.js

I have follow dependency part in package.json:我在 package.json 中有以下依赖部分:

"dependencies": {
    "bootstrap": "*",
    "bootstrap-datepicker": "^1.7.1",
    "bower": "^1.8.2",
    "chosen-js": "^1.8.2",
    "datatables.net-dt": "^1.10.16",
    "jQuery-QueryBuilder": "^2.4.5",
    "jquery": "^1.4",
    "jquery-tagit": "*",
    "jquery-ui-dist": "^1.12.1",
    "prismjs": "^1.8.1",
    "qtip2": "^3.0.3",
    "multi-step-modal": 
        "git+ssh://git@git.ias.su:2022/dependencies/multi-step-modal.git"
}

When I run npm update , I get:当我运行npm update时,我得到:

LPS@1.0.0 /home/opshenichnikova/NetBeansProjects/lps/public
├── bootstrap@4.0.0 
├── jQuery-QueryBuilder@2.5.0 
├── multi-step-modal@1.0.0  (git+ssh://git@git.ias.su:2022/dependencies/multi-step-modal.git#2f9bc29093c9939c2ba23fa18fd22001a74040d2)
├── UNMET PEER DEPENDENCY popper.js@^1.12.9
└── prismjs@1.12.2 

npm WARN bootstrap@4.0.0 requires a peer of popper.js@^1.12.9 but none was installed.

I searched for the reason and found just this: Bootstrap 4: Uncaught ReferenceError: Popper is not defined我搜索了原因并找到了这个: Bootstrap 4: Uncaught ReferenceError: Popper is not defined

I know that it is just warning, but I always keep my code warning-free.我知道这只是警告,但我总是让我的代码没有警告。

Popper.js is not really necessary Popper.js并不是必须的

Bootstrap 4.0.0 release contains 2 new files bootstrap.bundle.js and bootstrap.bundle.min.js which contain Popper.js inside and you really do not need it. Bootstrap 4.0.0 版本包含 2 个新文件bootstrap.bundle.jsbootstrap.bundle.min.js ,其中包含 Popper.js,你真的不需要它。

bootstrap.bundle.min.js is exactly Bootstrap.js + Popper.js. bootstrap.bundle.min.js就是 Bootstrap.js + Popper.js。

InBootstrap v4.0.0 documentation it is still mentioned that you need the file for some componentsBootstrap v4.0.0 文档中仍然提到您需要某些组件的文件

Components requiring JavaScript 需要 JavaScript 的组件

  • Dropdowns for displaying and positioning (also requires Popper.js )用于显示和定位的下拉菜单(也需要Popper.js
  • Tooltips and popovers for displaying and positioning (also requires Popper.js )用于显示和定位的工具提示和弹出窗口(也需要Popper.js

I have not tested it but I think it is not necessary我没有测试过,但我认为没有必要

Solutions解决方案

You can use the NPM path 'bootstrap/dist/js/bootstrap.bundle.js'.您可以使用 NPM 路径“bootstrap/dist/js/bootstrap.bundle.js”。

Or if you finally want to download Popper.js , download the version you need.或者,如果您最终想要下载Popper.js ,请下载您需要的版本。

bootstrap/package.json引导程序/package.json

Bootstrap 4.0.0 requires popper, so just add "popper.js": "^1.12.9" to the package.json Bootstrap 4.0.0需要 popper,所以只需将"popper.js": "^1.12.9"添加到 package.json

For example dropdown , tooltips and popovers won't work:例如dropdowntooltipspopovers将不起作用: 在此处输入图像描述

https://www.codeply.com/go/CuOfa7UnUA (broken w/o popper) https://www.codeply.com/go/CuOfa7UnUA (没有波普尔就坏了)

Note: As of 4.1 , popper.js is only required for dropdowns, tooltips and popovers.注意:从4.1开始,只有下拉菜单、工具提示和弹出框才需要popper.js。

If it is saying as follows image in, then如果是如下图所示,那么

在此处输入图像描述

It is asking for install popper.js for your project.它要求为您的项目安装 popper.js。 So get the cmd on your project location and run the following command.因此,在您的项目位置获取 cmd 并运行以下命令。

npm install popper.js --save

Then you can see as in following image.然后你可以看到如下图所示。

在此处输入图像描述

Have to add "popper.js":"^require_version" into package.json under the dependencies.必须将"popper.js":"^require_version"添加到依赖项下的 package.json 中。

You don't really need to install popper.js externally.你真的不需要在外部安装 popper.js。 Believe me, I was just installing the bootstrap, not in my working directory where I created the angular project and so encountered this issue, so you just need to install it in the project directory to avoid these issues.相信我,我只是安装引导程序,而不是在我创建角度项目的工作目录中,所以遇到了这个问题,所以你只需要将它安装在项目目录中就可以避免这些问题。 Mine worked 1000% every time I installed it in the proper directory/folder look at when installed in the project folder.每次我将它安装在正确的目录/文件夹中时,我的工作 1000% 查看安装在项目文件夹中的时间。

在项目文件夹中安装引导程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM