ReferenceError:未定义sourcemap

时间:2016-01-12 10:41:34

标签: npm gulp gulp-sass gulp-sourcemaps

我已经安装了gulp-sass和gulp-sourcemaps,我可以看到:node_modules中的文件夹。

我的gulpfile在这里:

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

// Sass Task
gulp.task('sass', function() {
    return gulp.src('src/scss/**/*.scss')
        .pipe(sourcemap.init())
        .pipe(sass({outputStyle:'compact'}).on('error', sass.logError))
        .pipe(sourcemap.write())
        .pipe(gulp.dest('css'));
});

// Watch Task
gulp.task('watch', function(){
    gulp.watch('src/scss/**/*.scss', ['sass']);
});

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

当我运行'gulp watch'并保存我的scss文件时,我收到此错误:

ReferenceError: sourcemap is not defined
    at Gulp.<anonymous> (/Users/Chudz/Documents/My Web/Project/gulpfile.js:16:9)
    at module.exports (/Users/Chudz/Documents/My Web/Project/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/Users/Chudz/Documents/My Web/Project/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Users/Chudz/Documents/My Web/Project/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Users/Chudz/Documents/My Web/Project/node_modules/orchestrator/index.js:134:8)
    at Gulp.<anonymous> (/Users/Chudz/Documents/My Web/Project/node_modules/gulp/index.js:36:18)
    at Gaze.<anonymous> (/Users/Chudz/Documents/My Web/Project/node_modules/glob-watcher/index.js:18:14)
    at emitTwo (events.js:87:13)
    at Gaze.emit (events.js:172:7)
    at Gaze.emit (/Users/Chudz/Documents/My Web/Project/node_modules/gaze/lib/gaze.js:129:32)

我出错的任何想法?

由于

1 个答案:

答案 0 :(得分:0)

正如我发布的那样,我看到了错误:)我有几次源代码写了源代码而不是源代码