Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

sass

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); }
                                                                          ^^^^^^^^^^^^^^^^^^
}
  • Dart Sass: v1.26.3 (https://www.npmjs.com/package/sass)
  • Sass-loader: v8.0.2 (https://www.npmjs.com/package/sass-loader)
like image 314
Chris Hayes Avatar asked Apr 20 '20 19:04

Chris Hayes


2 Answers

Figured it out. I needed to add

@use 'sass:math';

at the top of the file.

like image 163
Chris Hayes Avatar answered Nov 08 '22 20:11

Chris Hayes


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

like image 11
Antonina K Avatar answered Nov 08 '22 21:11

Antonina K