首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >angular2-cli给出了“多样式错误”

angular2-cli给出了“多样式错误”
EN

Stack Overflow用户
提问于 2016-10-13 15:58:13
回答 16查看 44.2K关注 0票数 18

我最近开始使用angular2-cli,并创建了一个新项目。我想在我的项目中使用引导程序,所以我安装了引导程序,然后像这里的angular2-cli指南所示的那样导入引导css文件。运行ng https://github.com/angular/angular-cli#global-library-installation服务后,我得到以下错误。

找不到多样式模块中的错误:错误:无法解决'/home/krishna/angular2_migrate/webui/node_modules/bootstrap/dist/css/bootstrap.min.css‘中的'/home/krishna/angular2_migrate/webui/node_modules/angular-cli/models’@多样式

我做错什么了?

关于angular2-cli版本的信息

代码语言:javascript
复制
krishna@Krishna:~/angular2_migrate/webui$ ng version
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
angular-cli: 1.0.0-beta.17
node: 4.4.3
os: linux x64
EN

回答 16

Stack Overflow用户

回答已采纳

发布于 2017-03-09 14:37:40

在路径前添加../。

在角-cli.json中,

代码语言:javascript
复制
"styles": [
  "../node_modules/bootstrap/dist/css/bootstrap.min.css",
  "styles.scss"
]

更新

在angular7中,有angular.json文件,您不需要添加../在路径之前

票数 22
EN

Stack Overflow用户

发布于 2019-02-01 02:51:16

在角7中,文件名为'angular.json‘。

确保为“样式”选项设置了正确的扩展集。在我的例子中,我安装了带有SCSS选项的角CLI,但是在默认情况下扩展被设置为SASS。

代码语言:javascript
复制
       "styles": [
          "src/styles.scss" // default was: src/styles.sass
        ],

票数 9
EN

Stack Overflow用户

发布于 2018-05-27 00:29:27

我使用的是角6,所以我的文件名是angular.json,但是我能够通过删除它所要求的"../“路径来解决类似的问题。下面是我添加引导和jquery到我的角度应用程序的设置。

代码语言:javascript
复制
   "styles": [
          "src/styles.css",
          "node_modules/bootstrap/dist/css/bootstrap.css"
        ],
        "scripts": ["../node_modules/jquery/dist/jquery.js",
          "node_modules/bootstrap/dist/js/bootstrap.bundle.js"
      ]

注释: jquery需要“./”,而不需要它。

根据我遇到的问题选择:

代码语言:javascript
复制
    "styles": [
          "src/styles.css", 
          "../node_modules/bootstrap/dist/css/bootstrap.css"
       ],
    "scripts": [
          "../node_modules/jquery/dist/jquery.js", 
          "../node_modules/bootstrap/dist/js/bootstrap.bundle.js"
      ]

此外,本文还包含了设置它的多个备选选项。

https://medium.com/@rogercodes1/intro-to-angular-and-how-to-setup-your-first-angular-app-b36c9c3ab6ca

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40025762

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档