2014-12-22 22 views
0

好的。我有這個代碼的麻煩。我之前使用過gulp-ruby-sass,但直到現在我還沒有遇到過這種錯誤。我正在使用gulp-ruby-sass 1.0.0。我只是試圖使用gulp-ruby-sass在css中運行我的sass文件。但是,這顯然不起作用。任何建議,將不勝感激。使用.pipe(sass({style:'expanded'))時,gulp-ruby-sass TypeError

這裏的錯誤:

TypeError: string is not a function 
    at Gulp.<anonymous> (/Users/xxxxxxxxxxx/xxxx/xxxxxxx/gulpfile.js:22:15) 
    at module.exports (/Users/xxxxxxxxxxx/xxxx/xxxxxxxx/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7) 
    at Gulp.Orchestrator._runTask (/Users/xxxxxxxxxxx/xxxx/xxxxxxx/node_modules/gulp/node_modules/orchestrator/index.js:273:3) 
    at Gulp.Orchestrator._runStep (/Users/xxxxxxxxxxx/xxxx/xxxxxxx/node_modules/gulp/node_modules/orchestrator/index.js:214:10) 
    at Gulp.Orchestrator.start (/Users/xxxxxxxxxxx/xxxx/xxxxxxx/node_modules/gulp/node_modules/orchestrator/index.js:134:8) 
    at /usr/local/lib/node_modules/gulp/bin/gulp.js:129:20 
    at process._tickCallback (node.js:442:13) 
    at Function.Module.runMain (module.js:499:11) 
    at startup (node.js:119:16) 
    at node.js:929:3 

我使用了我的項目咕嘟咕嘟代碼如下:

var gulp = require('gulp'), 
    sass = ('gulp-ruby-sass'), 
    uglify = require('gulp-uglify'), 
    livereload = require('gulp-livereload'), 
    plumber = require('gulp-plumber'), 
    jshint = require('gulp-jshint'); 

var paths = { 
    sass: 'stylesheets/scss/', 
    css: 'stylesheets/css' 
    }; 

gulp.task('lint', function() { 
    return gulp.src('angular/app.js') 
     .pipe(jshint()) 
     .pipe(jshint.reporter()); 
    }); 

gulp.task('sass', function() { 
    return gulp.src(paths.sass + '*.scss') 
     .pipe(plumber()) 
     .pipe(sass({style: 'expanded'})) // HERE IS WHERE THE ERROR OCCURS 
     .pipe(gulp.dest(paths.css + '*.css')) 
     .pipe(livereload()); 
    }); 

gulp.task('scripts', function() { 
    return gulp.src('angular/app.js') 
     .pipe(plumber()) 
     .pipe(uglify()) 
     .pipe(gulp.dest('angular/minjs')) 
     .pipe(livereload()); 
    }); 

gulp.task('watch', function() { 
    livereload.listen(); 
    gulp.watch(paths.sass + '*.scss', ['sass']); 
    gulp.watch('angular/app.js', ['scripts']); 
    }); 

gulp.task('default', ['lint', 'sass', 'scripts', 'watch']); 

回答

0

感謝@ APERCU爲察覺一開始不把require的錯誤('gulp-ruby-sass)。愚蠢的錯誤。

所以這裏是我從Gulp-Ruby-Sass 1.0.0-alpha的新文檔中得到的答案。新的文檔指出你必須擺脫gulp src。這是我用來使一切正常工作的代碼。

舊代碼

gulp.task('sass', function() { 
    return gulp.src(paths.sass + '*.scss') 
     .pipe(plumber()) 
     .pipe(sass({style: 'expanded'})) // HERE IS WHERE THE ERROR OCCURS 
     .pipe(gulp.dest(paths.css + '*.css')) 
     .pipe(livereload()); 
    }); 

新代碼

gulp.task('sass', function() { 
    return sass(paths.sass, {style: 'expanded'}) 
     .pipe(plumber()) 
     .pipe(gulp.dest(paths.css)) 
     .pipe(livereload()); 
}); 

注:新文檔不支持水珠。