twitter-bootstrap NPM 警告:[email protected] 需要 popper.js 的同级
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49256842/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NPM WARN: [email protected] requires a peer of popper.js
提问by Olga Pshenichnikova
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://[email protected]:2022/dependencies/multi-step-modal.git"
}
When I run npm update, I get:
当我运行时npm update,我得到:
[email protected] /home/opshenichnikova/NetBeansProjects/lps/public
├── [email protected]
├── [email protected]
├── [email protected] (git+ssh://[email protected]:2022/dependencies/multi-step-modal.git#2f9bc29093c9939c2ba23fa18fd22001a74040d2)
├── UNMET PEER DEPENDENCY popper.js@^1.12.9
└── [email protected]
npm WARN [email protected] 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.
我知道这只是警告,但我总是让我的代码没有警告。
回答by Enmanuel
Popper.jsis not really necessary
Popper.js并不是真正必要的
Bootstrap 4.0.0 release contains 2 new files bootstrap.bundle.jsand bootstrap.bundle.min.jswhich contain Popper.js inside and you really do not need it.
Bootstrap 4.0.0 版本包含 2 个新文件bootstrap.bundle.js,bootstrap.bundle.min.js其中包含 Popper.js,你真的不需要它。
bootstrap.bundle.min.jsis exactly Bootstrap.js + Popper.js.
bootstrap.bundle.min.js正是 Bootstrap.js + Popper.js。
In Bootstrap v4.0.0 documentationit is still mentioned that you need the file for some components
在Bootstrap v4.0.0 文档中仍然提到您需要某些组件的文件
Components requiring JavaScript
- Dropdowns for displaying and positioning (also requires Popper.js)
- Tooltips and popovers for displaying and positioning (also requires 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 v4.0.0
"popper.js": "^1.12.9"Bootstrap v4.1.1
"popper.js": "^1.14.1"
引导程序 v4.0.0
"popper.js": "^1.12.9"引导程序 v4.1.1
"popper.js": "^1.14.1"
回答by Zim
Bootstrap 4.0.0requires 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, tooltipsand popoverswon't work:

例如dropdown、tooltips和popovers将不起作用:

https://www.codeply.com/go/CuOfa7UnUA(broken w/o popper)
https://www.codeply.com/go/CuOfa7UnUA(没有 popper 损坏)
Note: As of 4.1, popper.js is only requiredfor dropdowns, tooltips and popovers.
注意:从4.1 开始,只有下拉菜单、工具提示和弹出框需要popper.js。
回答by Hemang
Have to add "popper.js":"^require_version"into package.json under the dependencies.
必须"popper.js":"^require_version"在依赖项下添加到 package.json 中。

