【问题标题】:Module build failed (from ./node_modules/sass-loader/lib/loader.js), Compound selectors may no longer be extended模块构建失败(来自 ./node_modules/sass-loader/lib/loader.js),复合选择器可能不再扩展
【发布时间】:2021-07-04 01:45:33
【问题描述】:

我在尝试运行 "npm start""ng serve" 时收到此错误。我正在使用 node 版本 v11.15.0,npm 版本 6.7.0

ERROR in ./src/app/shared/components/pop-up/pop-up.component.scss
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
                    @extend button.mat-button.default-button;
                           ^
      Compound selectors may no longer be extended.
Consider `@extend button, .mat-button, .default-button` instead.
    ╷
116 │                     @extend button.mat-button.default-button;
    │                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ╵
  stdin 116:29  root stylesheet
      in xyz/src/app/shared/components/pop-up/pop-up.component.scss (line 116, column 29)
ERROR in ./src/app/core/authentication/login/login.component.scss
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
            @extend button.mat-button.default-button;
                   ^
      Compound selectors may no longer be extended.
Consider `@extend button, .mat-button, .default-button` instead.
   ╷
59 │             @extend button.mat-button.default-button;
   │                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ╵
  stdin 59:21  root stylesheet
      in xyz/src/app/core/authentication/login/login.component.scss (line 59, column 21)
ERROR in ./src/app/modules/abc/components/scan-input/scan-input.component.scss
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
:host /deep/ .mat-radio-label {
     ^
      Expected selector.
   ╷
43 │ :host /deep/ .mat-radio-label{
   │       ^
   ╵
  stdin 43:7  root stylesheet
      in xyz/src/app/modules/abc/components/scan-input/scan-input.component.scss (line 43, column 7)
ℹ 「wdm」: Failed to compile.

我也尝试了一些解决方案,例如 -

npm rebuild node-sass
npm install --save-dev  --unsafe-perm node-sass
npm install node-sass

但不幸的是,没有一个对我有利。我需要帮助来解决这个问题。

【问题讨论】:

  • 你找到解决办法了吗?
  • @DiogoMagro 我已经在答案部分回答了解决方案

标签: javascript node.js angular webpack sass


【解决方案1】:

我自己尝试了一种解决方案,效果很好。处理上述样式的方式已经改变。所以,而不是

@extend button.mat-button.default-button;

会写成

@extend button, .mat-button, .default-button;

这个解决方案奏效了。

【讨论】:

    猜你喜欢
    • 2019-06-18
    • 2019-10-24
    • 2019-12-16
    • 2021-04-17
    • 2020-08-14
    • 2021-11-26
    • 2023-03-28
    • 2019-09-29
    相关资源
    最近更新 更多