Here's my 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);
});
All it does is copy files from one directory to another. When I run
gulp
it copies the files as expected. When I run
gulp watch
it runs the default
task as expected. When I modify a source file, I get the following error:
<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)
Am I doing something wrong besides using Windows? (edit: reproducible in OS X)
The second argument to gulp.watch
should either be an array or a function, not (as in your case) a string.
So use this instead:
gulp.watch(JADE_SRC, [ JADE_TASK ]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.