I
I
Illia T2020-07-12 18:24:11
Sass
Illia T, 2020-07-12 18:24:11

SCSS: why does it give an error when trying to import a component?

@import "/node_modules/materialize-css/sass/components/color-variables";


This is how I select the desired component using tooltips - after the slash, a directory appears with a list of other directories or files, so you can’t make a mistake in the address.
I work with VS Code, Live Server is running, automatic conversion from SCSS to CSS occurs when saving, and during this time it gives an error:

Error: File "f:\node_modules\materialize-css\sass\components\color-variables" not found
        on line 5 of sass/f:\projects\woodworks\src\scss\main.scss
>> @import "/node_modules/materialize-css/sass/components/color-variables";


This is the first line of imports followed by others.

Here is an example of the content of said component:

$purple: (
  "base":       #9c27b0,
  "lighten-5":  #f3e5f5,
  "lighten-4":  #e1bee7,
  "lighten-3":  #ce93d8,
  "lighten-2":  #ba68c8,
  "lighten-1":  #ab47bc,
  "darken-1":   #8e24aa,
  "darken-2":   #7b1fa2,
  "darken-3":   #6a1b9a,
  "darken-4":   #4a148c,
  "accent-1":    #ea80fc,
  "accent-2":    #e040fb,
  "accent-3":    #d500f9,
  "accent-4":    #aa00ff
);


Despite this error, I can prescribe classes inline, for example, class = "purple base" and everything is ok. But I would like to understand why the error appears.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question