Sass "Module loop: ... already being loaded" in CI
The Sass module system forbids circular @use chains. "Module loop: this module is already being loaded" means file A uses B while B (directly or transitively) uses A, which has no defined evaluation order.
What this error means
The Sass build fails with "Error: Module loop: this module is already being loaded." naming the file at the point the cycle closes.
sass
Error: Module loop: this module is already being loaded.
+-> src/styles/theme.scss
| @use 'colors';
| ^^^^^^^^^^^^^^^Common causes
Two modules @use each other
A direct cycle (theme uses colors, colors uses theme) cannot be loaded in a single order, so Sass rejects it.
A transitive cycle through shared partials
A longer chain of @use eventually loops back to a module already on the load stack.
How to fix it
Break the cycle with a shared base module
- Identify the two modules that reference each other.
- Extract the shared variables or mixins into a third partial both can
@use. - Remove the back-reference so the graph is acyclic, then rebuild.
styles/_tokens.scss
// _tokens.scss holds shared values
// theme.scss and colors.scss both @use 'tokens';Use @forward for re-exports
If one module only needs to expose another's members, @forward instead of @use to flatten the graph and avoid a loop.
How to prevent it
- Keep shared tokens in a leaf partial that other modules
@use. - Avoid mutual
@usebetween two stylesheets. - Use
@forwardfor re-exports instead of circular@use.
Related guides
Sass "Undefined mixin" in CIFix "Error: Undefined mixin" from dart-sass in CI - an @include references a mixin that was never defined or…
Sass "@import is deprecated" deprecation warning in CIFix Sass "Deprecation Warning: Sass @import rules are deprecated" in CI - dart-sass warns on @import and a st…
Sass "legacy JS API is deprecated" in CIFix Sass "The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0" in CI - a tool calls render…