我今天尝试将我的项目更新到 angular 8.0.0,但我遇到了引导程序问题,我找不到解决方案。
我使用引导程序 4.3.1
当我这样做时ng serve
,我收到此错误:
ERROR in ./node_modules/bootstrap/scss/bootstrap.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--13-3!./node_modules/bootstrap/scss/bootstrap.scss)
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
@each $color, $value in $colors {
^
Undefined variable.
╷
3 │ @each $color, $value in $colors {
│ ^^^^^^^
╵
node_modules/bootstrap/scss/_root.scss 3:27 @import
stdin 11:9 root stylesheet
in ./node_modules/bootstrap/scss/_root.scss (line 3, column 27)
在我的 angular.json 中,我有这个(我只包括了与 scss 相关的部分):
"schematics": {
"@schematics/angular:component": {
"style": "sass"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets",
"src/manifest.json"
],
"styles": [
"./node_modules/bootstrap/scss/bootstrap.scss",
"./node_modules/c3/c3.css",
"./node_modules/@fortawesome/fontawesome-free/css/all.css",
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"./src/styles/styles.scss"
],
"stylePreprocessorOptions": {
"includePaths": [
"src/styles"
]
},
"scripts": [],
"es5BrowserSupport": true
},
根据我对错误的理解,这是由于全局 scss 变量不可用,在 中"./node_modules/bootstrap/scss/bootstrap.scss"
,它看起来像这样:
@import "functions";
@import "variables";
@import "mixins";
@import "root";
@import "many_other_stuff"
$colors 变量在 中定义"variables"
,因此它应该在 中可用"root"
。
知道我在这里做错了什么吗?