我刚刚将CLI项目升级到Angular 5 / CLI 1.5,无论我做什么,我都会从Bootstrap 4中获取错误。这是主要错误:
ERROR in ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_modules/postcss-loader?{"ident":"postcss"}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":false,"precision":8,"includePaths":[]}!./src/styles.scss
Module build failed:
@return mix($color-base, $color, $level * $theme-color-interval);
^
Argument `$color-2` of `mix($color-1, $color-2, $weight: 50%)` must be a color
我的Bootstrap安装基本上是通过scss导入我想要的东西,而不是整个东西。
一直在运作的导入:
@import "~bootstrap/scss/functions";
@import "~bootstrap/scss/variables";
@import "~bootstrap/scss/mixins";
@import "~bootstrap/scss/reboot";
@import "~bootstrap/scss/bootstrap-grid";
@import "~bootstrap/scss/tables";
@import "~bootstrap/scss/alert";
@import "~bootstrap/scss/utilities";
我也尝试导入整个事情来调试问题但是出现了同样的错误:
@import "~bootstrap/scss/bootstrap";
我已经阅读了关于这个问题的旧帖子,说它很久以前已经解决了,但我无法绕过它。有没有人遇到这个问题并想出来了?
工作流:
npm install
ng serve
(我使用的是全局CLI,而不是本地的)节点版本:8.9.0
NPM版本:5.5.1
这是我的设置:
"dependencies": {
"@angular/animations": "^5.0.0",
"@angular/cdk": "^5.0.0-rc0",
"@angular/cli": "^1.5.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/compiler-cli": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/language-service": "^5.0.0",
"@angular/material": "^5.0.0-rc0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/platform-server": "^5.0.0",
"@angular/router": "^5.0.0",
"bootstrap": "^4.0.0-beta.2",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"lodash": "^4.17.4",
"rxjs": "^5.5.2",
"socket.io-client": "^2.0.4",
"zone.js": "^0.8.18"
},
"devDependencies": {
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/lodash": "^4.14.77",
"@types/node": "~8.0.5",
"codelyzer": "~4.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.3.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2"
}
答案 0 :(得分:1)
原来我回答了我自己的问题,说我没有使用darken
mixin。我在Bootstrap之前包含的变量文件中调用了一个。我把它移下来,一切都恢复了。
奇怪的是,这段代码在几个月内没有改变,并且工作正常。我现在猜测编译器很挑剔。
答案 1 :(得分:-1)
确保节点在运行后更新到最新版本: npm update -g 更新所有包,或 npm update [package-name]
答案 2 :(得分:-1)
包括引导程序
Bootstrap是一种流行的CSS框架,可以在Angular项目中使用。本指南将引导您将引导程序添加到Angular CLI项目并将其配置为使用引导程序。
安装Bootstrap
随着新项目的创建和准备,您接下来需要将bootstrap作为依赖项安装到项目中。使用--save选项,依赖项将保存在package.json
中npm install bootstrap --save
npm install bootstrap@next --save
配置项目 完成后,它应如下所示:
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"styles.css"
],
了解更多信息
https://github.com/angular/angular-cli/blob/master/docs/documentation/stories/include-bootstrap.md