angular - 在 Angular 6 中导入 Bootstrap angular.json 错误 : ENOENT: no such file or directory

标签 angular bootstrap-4

在 Angular 6 中导入 bootstrap 的正确方法是什么。在以前的版本中我是这样做的并且它工作正常。

angular-cli.json( Angular 5)

"styles": [
    "styles.scss"
  ],
"scripts": [
    "../node_modules/jquery/dist/jquery.slim.min.js",
    "../node_modules/popper.js/dist/umd/popper.min.js",
    "../node_modules/bootstrap/dist/js/bootstrap.min.js"
  ],

angular.json( Angular 6)

"styles": [
          "src/styles.css"
        ],
"scripts": [
          "../node_modules/jquery/dist/jquery.slim.min.js",
          "../node_modules/popper.js/dist/umd/popper.min.js",
          "../node_modules/bootstrap/dist/js/bootstrap.min.js"
        ]

获取错误:

Error: ENOENT: no such file or directory, open '/Users/pacozevallos/myApp/node_modules/jquery/dist/jquery.slim.min.js'

最佳答案

此配置应该有效,因为正如您在 angular.json 文件中看到的那样,有属性 "root": "", 用于导入文件,因此请遵循以下代码

"styles": [
   "src/styles.scss",
   "node_modules/bootstrap/dist/css/bootstrap.min.css"
],
"scripts": [
   "node_modules/jquery/dist/jquery.slim.min.js",
   "node_modules/popper.js/dist/umd/popper.min.js",
   "node_modules/bootstrap/dist/js/bootstrap.min.js"
]

关于angular - 在 Angular 6 中导入 Bootstrap angular.json 错误 : ENOENT: no such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50280575/

相关文章:

angularjs - 如何在 Angular 混合应用程序中的组件之间进行通信?

angular - 防止用户在文本框中触发空格

css - Bootstrap v4 导航栏断点

html - Bootstrap 4 左右对齐 div,对于小屏幕,将它们显示在不同的行中

html - 在 IE 中使用 CSS column-width 时自定义 Bootstrap 复选框呈现错误

javascript - Angular2 应用程序一半使用 Typescript 和 Javascript

angular - 我们可以有两个具有相同选择属性的 ng-content 吗?

angular - 类型错误 : Cannot read property 'flags' of undefined

css - 如何实现这种布局?表格标题未与内容对齐,每行的内容也未垂直对齐

javascript - 折叠 sm 和/或 md 屏幕上的 Bootstrap 卡