Bootstrap 5 + SASS 错误: 未定义的 MIXIN @include _assert-ascending。

9

我正在学习SCSS,跟着freecodecamp的教程学习,但在使用实时SASS的CLI时一直出现以下错误:watch:

Error: Undefined mixin.
    ╷
320@include _assert-ascending($grid-breakpoints, "$grid-breakpoints");
    │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ╵
  node_modules\bootstrap\scss\_variables.scss 320:1  @use
  node_modules\bootstrap\scss\bootstrap.scss 11:1    @import
  scss\_custom.scss 58:8                             @use
  scss\style.scss 1:1  

有没有更有经验的SASS用户能指点我一下,我不知道该从哪里开始。我需要在custom.scss中添加imports或@use吗?

2个回答

21

我曾经遇到过这个问题。我的问题在于我导入的顺序错误了:

@import '../node_modules/bootstrap/scss/mixins';
@import '../node_modules/bootstrap/scss/functions';
@import '../node_modules/bootstrap/scss/variables';

我将其更改为来摆脱它。
@import '../node_modules/bootstrap/scss/functions';
@import '../node_modules/bootstrap/scss/variables';
@import '../node_modules/bootstrap/scss/mixins';

你需要按照特定的顺序引入这三个模块。你可能缺少其中一个模块或者将它们的顺序写错了。

0

我应该在哪里包含functions.css?我对这部分感到困惑,我查看了线程但无法使其正常工作。 - Joe Rodriguez
应该全部都包含在bootstrap.scss中,包括变量。我在构建一些Angular组件时遇到了问题,只包含了几个Bootstrap组件。 - Mark Handy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接