Sass Bootstrap&;角度8。_root.scss中未定义的变量

Sass Bootstrap&;角度8。_root.scss中未定义的变量,sass,bootstrap-4,angular-cli,angular8,Sass,Bootstrap 4,Angular Cli,Angular8,今天我尝试将我的项目更新到angular 8.0.0,但我遇到了bootstrap的问题,无法找到解决方案 我使用bootstrap4.3.1 当我执行ng服务时,我得到以下错误: ERROR in ./node_modules/bootstrap/scss/bootstrap.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modu

今天我尝试将我的项目更新到angular 8.0.0,但我遇到了bootstrap的问题,无法找到解决方案

我使用bootstrap4.3.1

当我执行
ng服务时
,我得到以下错误:

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中,我有以下内容(我只包括了与SCS相关的部分):

根据我对错误的理解,这是由于全局scss变量不可用,在
“/node\u modules/bootstrap/scss/bootstrap.scss”
中,它看起来如下所示:

@import "functions";
@import "variables";
@import "mixins";
@import "root";
@import "many_other_stuff"
$colors变量是在
的“变量”
中定义的,因此它应该在
的“根”
中可用


知道我做错了什么吗?

请查看此Stackblitz,并比较您的package.json、angular.json(以及其他相关文件)以查看是否遗漏了安装某些依赖项。此Stackblitz具有angular 8.0.0,并使用bootstrap 4.3.1

您需要在package.json中添加这些内容来安装引导程序,并在angular 8.0中使用它的scss版本

"bootstrap": "4.3.1",
"jquery": "1.9.1 - 3",
"popper.js": "^1.14.7",
"node-sass": "4.7.2",

它应该是SCS而不是sass:

"schematics": {
    "@schematics/angular:component": {
      "style": "scss"
    }
  },

谢谢

谢谢,我尝试了这个,但没有改变任何东西。我有这些依赖项,但看看你的Stackblitz,我发现了一个我没有解决问题的依赖项:节点sass。我安装了它,它现在正在工作。编辑您的答案以添加此内容,我将接受此内容。我本可以在您之前提出的问题上赢得奖金:(.很遗憾您没有看到此答案请检查我的答案。嘿,没有问题:)很高兴提供帮助
"schematics": {
    "@schematics/angular:component": {
      "style": "scss"
    }
  },