我使用以下gulpfile配置:
gulp.task('watch', (cb) => {
pump([
nodemon({
script: './server.js',
ext: 'js',
ignore: [ './dist', './public' ]
}),
gulp.watch('public/js/**/*.js', [ 'build-js' ]),
gulp.watch('public/less/**/*.less', [ 'build-css' ]),
gulp.watch([ 'public/views/**/*.html', 'public/index.html' ], [ 'build-html' ])
], cb)
})
每当服务器文件发生更改时,它都会重新启动服务器,或者只要./public
中的文件发生更改,就会运行相应的构建任务。构建任务只是简单的缩小和连接任务,这些任务可以自行运行,因此不是问题。现在每当我运行它,我得到以下stacktrace:
[15:52:51] 'watch' errored after 69 ms
[15:52:51] TypeError: from.pipe is not a function
at pipe (/home/linux/IdeaProjects/project/node_modules/pump/index.js:54:15)
at Array.reduce (native)
at pump (/home/linux/IdeaProjects/project/node_modules/pump/index.js:77:18)
at Gulp.gulp.task (/home/linux/IdeaProjects/project/gulpfile.js:56:5)
at module.exports (/home/linux/IdeaProjects/project/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/home/linux/IdeaProjects/project/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/home/linux/IdeaProjects/project/node_modules/orchestrator/index.js:214:10)
at Gulp.Orchestrator.start (/home/linux/IdeaProjects/project/node_modules/orchestrator/index.js:134:8)
at /home/linux/IdeaProjects/project/node_modules/gulp/bin/gulp.js:129:20
at _combinedTickCallback (internal/process/next_tick.js:67:7)
gulpfile.js:56
对应于我在上面发布的配置中的pump([
行。
有趣的是,尽管有错误,但我的配置运行完美无缺。当我更新一些文件时,它会执行正确的任务。
那么我该怎么做才能摆脱这个错误呢?这是一个错误,还是我错过了什么?