这是我的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);
});
它所做的只是将文件从一个目录复制到另一个目录。当我跑
gulp
它按预期复制文件。当我跑
gulp watch
它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)
除了使用 Windows 之外,我做错了什么吗?(编辑:可在 OS X 中重现)