Node-sass: Undefined variable: "$import-counter" ini plugin "sass" [BUG?]

Created on 18 Oct 2016  路  7Comments  路  Source: sass/node-sass

  • NPM version (npm -v): 3.10.3
  • Node version (node -v): 6.60
  • Node Process (node -p process.versions):
{ http_parser: '2.7.0',
node: '6.6.0',
v8: '5.1.281.83',
uv: '1.9.1',
zlib: '1.2.8',
ares: '1.10.1-DEV',
icu: '57.1',
modules: '48',
openssl: '1.0.2h' }
  • Node Platform (node -p process.platform): darwin
  • Node architecture (node -p process.arch): x64
  • node-sass version (node -p "require('node-sass').info"):
node-sass   3.10.1  (Wrapper)   [JavaScript]
libsass     3.3.6   (Sass Compiler) [C/C++]
  • npm node-sass versions (npm ls node-sass):

When encountering a syntax, or compilation issue:

I will gladly open the issue under LibSass as well if that is the proper location. I'm running a Gulp build with the above Node specs. Using Gulp-sass 2.3.2. I've never had an issues with Gulp-sass before.

When I init Gulp, I get the following error in the console:

Error in plugin 'sass'
Message:
    node_modules/node-sass/test/fixtures/depth-first/_vars.scss
Error: Undefined variable: "$import-counter".
        on line 1 of node_modules/node-sass/test/fixtures/depth-first/_vars.scss
>> $import_counter: $import_counter + 1;
   -----------------^
External - Gulp Sass Invalid - By Design

Most helpful comment

@rdwatters @filip88
If sassfles contains node_module please remove it

const sassfiles = 'path to src/**/*.scss';

All 7 comments

This isn't valid Sass. You can try this on Sassmeister as an example

$undefinedVariable: $undefinedVariable + 1;

You're trying to add an undefined variable to itself. That's whay the message is telling you.

@nschonni I'm glad you acknowledge that it is not valid SASS...but I didn't write it. It's part of this very repo:

https://github.com/sass/node-sass/blob/master/test/fixtures/depth-first/_vars.scss

See the full console error up top. I'm not sure why this is being hyphenated when it looks like the original is snake case.

Also, it _is_ defined in index.scss of that same directory. Thoughts?

If you look at the blame you can see that it is testing #1420/#980 so it is importing that file more than once. I don't see how you would be hitting an internal mocha test fixture running gulp-sass unless it's using something overly broad and globbing everything in the node_modules directory

AHA! My F-up on my Gulpfile.js...

const sass = require('gulp-sass');
const sassfiles = '**/*.scss';

gulp.task('sass', () => {
return gulp.src(sassfiles)
.pipe
....
});

Switching my sassfiles variable did the trick. Appreciate you looking into this @nschonni !

@rdwatters
I have same issue but I didn't understand how did you solve this issue?

@rdwatters @filip88
If sassfles contains node_module please remove it

const sassfiles = 'path to src/**/*.scss';

@filip88
Instead of processing node_modules' sass files, you'll want to only include your project's sass files.
For example:
Change styles: './**/*.scss', to styles: 'sass/**/*.scss',
Take note that I've specified a folder for my sass files I'd like to process.

Was this page helpful?
0 / 5 - 0 ratings