SassError: There is no module with the namespace "math"
SassSass 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); }
^^^^^^^^^^^^^^^^^^
}
- Dart Sass: v1.26.3 (https://www.npmjs.com/package/sass)
- Sass-loader: v8.0.2 (https://www.npmjs.com/package/sass-loader)
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