147

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); }
                                                                          ^^^^^^^^^^^^^^^^^^
}
Chris Hayes
  • 11,505
  • 6
  • 33
  • 41

2 Answers2

363

Figured it out. I needed to add

@use 'sass:math';

at the top of the file.

Chris Hayes
  • 11,505
  • 6
  • 33
  • 41
  • 19
    why is this not documented straight in https://sass-lang.com/documentation/modules/math!? thanks a lot!!! – denns Sep 20 '21 at 12:14
  • 1
    @denns to be fair, it is documented at: https://sass-lang.com/documentation/modules – xorinzor Sep 26 '21 at 13:19
  • yeah that is where i found it, but originally i endet up in the examples section, where the examples did not work because of this. – denns Sep 27 '21 at 12:26
13

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

Antonina K
  • 425
  • 4
  • 12