【问题标题】:Bootstrap requires popper.js despite bundle when used in AngularBootstrap 在 Angular 中使用时需要 popper.js,尽管 bundle
【发布时间】:2020-11-16 04:26:05
【问题描述】:

我通过npm 安装了bootstrap@next (v5.0.0-alpha1)。我将捆绑JS添加到脚本中,但编译后收到此错误:

ERROR in ./node_modules/bootstrap/dist/js/bootstrap.esm.js
Module not found: Error: Can't resolve 'popper.js' in
'./foo/node_modules/bootstrap/dist/js'

README 明确指出(粗体字):

我们提供编译后的 CSS 和 JS (bootstrap.),以及编译和缩小的 CSS 和 JS (bootstrap.min.)。源映射 (bootstrap.*.map) 可用于某些浏览器的开发工具。 捆绑的 JS 文件(bootstrap.bundle.js 和缩小的 bootstrap.bundle.min.js)包括 Popper。

angular.json

"scripts": [
    "node_modules/bootstrap/dist/js/bootstrap.bundle.js",
],

知道我在这里会错过什么吗?

【问题讨论】:

  • 您似乎正在尝试在应用程序的某个位置导入引导程序,除了 angular.json。删除它,它应该可以正常工作

标签: javascript angular twitter-bootstrap bootstrap-5


【解决方案1】:

只要在 package.json 中列出 popper 就足够了。我遇到了同样的问题,删除“node_modules/bootstrap/dist/js/bootstrap.bundle.js”后它对我有用。

【讨论】:

  • 很好奇,为什么我需要列出它,因为它是 bootstrap.bundle.js 的一部分?还是我误会了?
猜你喜欢
  • 1970-01-01
  • 2018-02-19
  • 2019-11-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-23
  • 2017-05-06
相关资源
最近更新 更多