SassError: There is no module with the namespace "math"

Sass

Sass Problem Overview


I'm having trouble getting the math SASS library to work in a Vue app. It compiles with Dart Sass, and sass-loader. The Dart Sass version is 1.26.3, so the math module should work.

Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: There is no module with the namespace "math".

@for $i from 2 through 10 
    &:nth-child(#{$i}) { transition-duration: 300ms + $i * 50ms - 400ms * math.floor($i / 8); }
                                                                          ^^^^^^^^^^^^^^^^^^
}

Sass Solutions


Solution 1 - Sass

Figured it out. I needed to add

@use 'sass:math';

at the top of the file.

Solution 2 - Sass

What I could recommend you is an automatic (lazy) way - you may use:

$ npm install -g sass-migrator
$ sass-migrator division **/*.scss

From: https://sass-lang.com/documentation/breaking-changes/slash-div#automatic-migration

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionChris HayesView Question on Stackoverflow
Solution 1 - SassChris HayesView Answer on Stackoverflow
Solution 2 - SassAntonina KView Answer on Stackoverflow