Sass Gulp任务得到" TypeError:对象css /没有方法' on'""

时间:2014-11-14 18:11:14

标签: node.js sass gulp

我有一个gulp任务使用gulp-sass插件,我基于插件README中包含的插件:

gulp.task('sass', function () {
    gulp.src('app/sass/')
        .pipe(plugins.sourcemaps.init())
        .pipe(sass())
        .pipe(plugins.sourcemaps.write())
        .pipe('app/css/');
});

但它始终失败:

TypeError: Object app/css/ has no method 'on'
    at Stream.pipe (stream.js:65:8)
    at Gulp.gulp.task.gulp.src.read (/app/gulpfile.js:114:10)
    at module.exports (/app/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/app/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/app/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/app/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:419:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)

这里发生了什么?你会认为README中的例子是有效的。

1 个答案:

答案 0 :(得分:0)

输出目录中的README缺少gulp.dest。它添加了正确的工作:

gulp.task('sass', function () {
    gulp.src('app/sass/')
        .pipe(plugins.sourcemaps.init())
        .pipe(sass())
        .pipe(plugins.sourcemaps.write())
        .pipe(gulp.dest('app/css/'));
});