1

これが私のもの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で再現可能)

4

1 に答える 1

6

の2番目の引数gulp.watchは、(あなたの場合のように)文字列ではなく、配列または関数のいずれかでなければなりません。

代わりにこれを使用してください:

gulp.watch(JADE_SRC, [ JADE_TASK ]);
于 2014-02-04T08:10:59.833 に答える