3

今日、プロジェクトを 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"

私がここで間違っていることは何か分かりますか?

4

2 に答える 2