Getting Undefined variable error when compiling SCSS using node-sass



"scripts": {
  "compile:sass": "node-sass sass/main.scss css/style.css -w"


@import "abstracts/variables";
@import "base/typography";  


$color-light-grey: #777;
$color-white: #fff;   


body {
  color: $color-light-grey;
.heading-primary {
  color: $color-white;

Now my issue is when I’m trying to compile with npm run compile:sass it throws the following error:

“message”: “Undefined variable: \”$color-light-grey\”.”


Looks like there are two errors in your code above:

  • You import "abstracts/variables" but, at least in the text, the file name seems to be _variables.scss (missing an “s”)
  • You should import "abstracts/variables" before everything else.

Like that:

@import "abstracts/variables";
@import "base/typography";

Answered By – David Tanzer

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published