我正在配置gulp文件,但遇到以下错误:
Starting 'html'...
[23:44:40] Finished 'html' after 8.42 ms
[23:44:40] Finished 'html' after 4.54 ms
[23:44:40] Starting 'html'...
[23:44:40] 'html' errored after 646 μs
[23:44:40] TypeError: dest.on is not a function
at DestroyableTransform.Stream.pipe (internal/streams/legacy.js:30:8)
at Gulp.<anonymous> (D:\web_forum\gulpfile.js:17:10)
at module.exports (D:\web_forum\node_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (D:\web_forum\node_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (D:\web_forum\node_modules\orchestrator\index.js:214:10)
at Gulp.Orchestrator.start (D:\web_forum\node_modules\orchestrator\index.js:134:8)
at Gulp.<anonymous> (D:\web_forum\node_modules\gulp\index.js:36:18)
at Gaze.<anonymous> (D:\web_forum\node_modules\glob-watcher\index.js:18:14)
at emitTwo (events.js:126:13)
at Gaze.emit (events.js:214:7)
[23:44:40] Starting 'html'...
[23:44:40] Finished 'html' after 4.21 ms
[Browsersync] Reloading Browsers...
这是在源代码的de html部分更改后生成的错误。跟踪是由gulp.watch()任务启动的
我正在使用以下gulpfile:
const gulp = require('gulp');
const uglify = require('gulp-uglify');
const sass = require('gulp-sass');
const concat = require('gulp-concat');
const htmlPartial = require('gulp-html-partial');
const htmlmin = require('gulp-htmlmin');
const cleanCSS = require('gulp-clean-css');
var browserSync = require('browser-sync').create();
var runSequence = require('run-sequence');
gulp.task('html', function(){
return gulp.src('src/html/*.html')
.pipe(htmlPartial({
basePath: 'src/html/partials/'
}))
.pipe(gulp.dest('dist/'))
.pipe(browserSync.reload());
});
gulp.task('build_html', function(){
return gulp.src('src/html/*.html')
.pipe(htmlPartial({
basePath: 'src/html/partials/'
}))
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('dist/'));
});
gulp.task('build_sass', function(){
return gulp.src('src/sass/*scss')
.pipe(sass().on('error', sass.logError))
.pipe(concat('style.min.css'))
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest('dist/css'));
});
gulp.task('sass', function(){
return gulp.src('src/sass/*scss')
.pipe(sass().on('error', sass.logError))
.pipe(concat('style.min.css'))
.pipe(gulp.dest('dist/css'));
});
gulp.task('scripts', function(){
return gulp.src('src/js/*.js')
.pipe(concat('main.js'))
.pipe(gulp.dest('dist/js'));
});
gulp.task('build_scripts', function(){
return gulp.src('src/js/*.js')
.pipe(concat('main.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/js'));
});
gulp.task('images', function(){
return gulp.src('src/images/*')
.pipe(gulp.dest('dist/images'));
});
gulp.task('serve', function() {
browserSync.init({
server: "./dist"
});
gulp.watch("src/html/**/*.html", ['html']);
gulp.watch("src/js/*.js", ['scripts']);
gulp.watch("src/sass/*.scss", ['sass']);
gulp.watch("src/images/*", ['images']);
});
gulp.task(serve)通过gulp客户端在控制台中运行, 这将启动流服务器,并启动监视处理程序。 错误发生在gulp.task(html)中。其他任务尚不包含任何流命令。
有人知道如何解决此问题吗?
谢谢