gulp.watch TypeError:string不是函数

Dis*_*tum 1 javascript gulp

这是我的gulpfile.js:

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

var DEST_BASE = 'dist';
var JADE_TASK = 'jade';
var JADE_SRC = 'app/**/ui/*.jade';
var JADE_DEST = DEST_BASE + '/dist/app';

gulp.task(JADE_TASK, function() {
    return gulp.src(JADE_SRC).pipe(gulp.dest(JADE_DEST));
});

gulp.task('clean', function() {
    return gulp.src(DEST_BASE, {read: false}).pipe(clean());
});

gulp.task('default', ['clean'], function() {
    gulp.start(JADE_TASK);
});

gulp.task('watch', ['default'], function(){
    gulp.watch(JADE_SRC, JADE_TASK);
});
Run Code Online (Sandbox Code Playgroud)

它只是将文件从一个目录复制到另一个目录.我跑的时候

gulp
Run Code Online (Sandbox Code Playgroud)

它按预期复制文件.我跑的时候

gulp watch
Run Code Online (Sandbox Code Playgroud)

default按预期运行任务.当我修改源文件时,我收到以下错误:

<PROJECT_ROOT>\node_modules\gulp\node_modules\vinyl-fs\node_modules\glob-watcher\index.js:17
      if(cb) cb(outEvt);
             ^
TypeError: string is not a function
    at Gaze.<anonymous> (<PROJECT_ROOT>\node_modules\gulp\node_modules\vinyl-fs\node_modules\glob-watcher\index.js:17:14)
    at Gaze.EventEmitter.emit (events.js:98:17)
    at Gaze.emit (<PROJECT_ROOT>\node_modules\gulp\node_modules\vinyl-fs\node_modules\glob-watcher\node_modules\gaze\lib\gaze.js:120:32)
    at <PROJECT_ROOT>\node_modules\gulp\node_modules\vinyl-fs\node_modules\glob-watcher\node_modules\gaze\lib\gaze.js:393:16
    at StatWatcher._pollers.(anonymous function) (<PROJECT_ROOT>\node_modules\gulp\node_modules\vinyl-fs\node_modules\glob-watcher\node_modules\gaze\lib\gaze.js:316:7)
    at StatWatcher.EventEmitter.emit (events.js:98:17)
    at StatWatcher._handle.onchange (fs.js:1104:10)
Run Code Online (Sandbox Code Playgroud)

除了使用Windows,我做错了吗?(编辑:可在OS X中重现)

rob*_*lep 6

第二个参数gulp.watch应该是数组或函数,而不是(如在您的情况下)字符串.

所以请改用:

gulp.watch(JADE_SRC, [ JADE_TASK ]);
Run Code Online (Sandbox Code Playgroud)