在angular 6 angular.json中导入bootstrap错误:ENOENT:没有这样的文件或目录 [英] import bootstrap in angular 6 angular.json Error: ENOENT: no such file or directory

查看:93
本文介绍了在angular 6 angular.json中导入bootstrap错误:ENOENT:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Angular 6中导入引导程序的正确方法是什么?在以前的版本中,我是这样做的,并且可以正常工作.

What is the correct way to import bootstrap in Angular 6. In previous versions I did it this way and it worked correctly.

angular-cli.json (Angular 5)

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)

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": "",用于导入文件,因此请遵循以下代码

This configuration should work because as you see in angular.json file there is property "root": "", for importing files, so follow below piece of code

"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 6 angular.json中导入bootstrap错误:ENOENT:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆