7

I get an error after I start gulp. I have taken out all other plugins to find problem:

[gulp-sass] source string:1: error: invalid top-level expression

gulpfile.js:

var gulp = require('gulp');
var sass = require('gulp-sass');

gulp.task('sass', function() {
    gulp.src('app/assets/sass/styles.sass')
        .pipe(sass({
            errLogToConsole: true
        }))
        .pipe(gulp.dest('public_html/assets/css'))
});

gulp.task('default', ['sass'], function() {
    gulp.watch("app/assets/sass/*.sass", ['sass']);
});

Windows 7

4
  • 2
    The problem might be in your SASS...
    – elclanrs
    Jun 15, 2014 at 1:06
  • problem is not in the sass file. I checked with the sass file only having two lines just to make sure.
    – Joel Z.
    Jun 15, 2014 at 2:29
  • I found the problem but not solution. If I change the gulp.src to anything other than what it's currently set (the existing correct directory) the error will go away.
    – Joel Z.
    Jun 16, 2014 at 3:37
  • SASS has two syntaxes — SASS and SCSS. I got this error after switching from SCSS to SASS. You haven't provided your SASS file so I have to guess, but from what you've said it's probably the same cause. @mastertinner's answer has the solution. Feb 21, 2015 at 22:27

3 Answers 3

13

If you want to use the indented syntax (.sass) as the top level file, use

pipe(sass({ indentedSyntax: true }))

instead of

pipe(sass()).

0
4

Can you try to use the option sourceComments and set it to normal in your sass ? It seems to have some problems if you don't pass it.

So try to change your task as follow :

gulp.task('sass', function () {

  gulp.src('app/assets/sass/styles.sass')
    .pipe(sass({
        errLogToConsole: true,
        sourceComments : 'normal'
    }))
    .pipe(gulp.dest('public_html/assets/css'))
});

See the related issue of gulp-sass. Alternatively, you can still use gulp-ruby-sass.

0

Hilariously, the problem for me was that the plugin gulp-sass ignores the extension of the top level file and parses as SCSS no matter what.

Includes worked correctly, so the solution was to make a one liner inclusion at the top.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.