Olá,
Estou tentando rodar o gulp, mas em uma das tasks está dando o erro "write after end". Segue meu gulpfile.js:
var gulp = require('gulp'),
imagemin = require('gulp-imagemin'),
clean = require('gulp-clean'),
uglify = require('gulp-uglify'),
usemin = require('gulp-usemin'),
cssmin = require('gulp-clean-css'),
rev = require('gulp-rev'),
autoprefixer = require('gulp-autoprefixer'),
htmlmin = require('gulp-htmlmin');
gulp.task('copy', function(){
return gulp.src('./src/**/*')
.pipe(gulp.dest('./min/'));
});
gulp.task('clean', function(){
return gulp.src('./min')
.pipe(clean());
});
gulp.task('build-img', function(){
gulp.src('./min/imgs/*.jpg')
.pipe(imagemin())
.pipe(gulp.dest('./min/imgs/'));
gulp.src('./min/imgs/*.png')
.pipe(imagemin())
.pipe(gulp.dest('./min/imgs/'));
});
gulp.task('minif-html', function(){
gulp.src('./min/*.html')
.pipe(usemin({
js: [ uglify(), rev() ],
css: [ autoprefixer(), cssmin(), rev() ],
html: [htmlmin({ collapseWhitespace: true })]
}))
.pipe(gulp.dest('./min/'));
});
gulp.task('default',
gulp.series('clean', 'copy',
gulp.parallel('minif-html', 'build-img')));
Segue o package.json:
{
"name": "projeto-teste",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"gulp": "gulp"
},
"repository": {
"type": "git",
"url": "git+https://gitlab.com/puzzletech/projeto-teste.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://gitlab.com/puzzletech/projeto-teste/issues"
},
"homepage": "https://gitlab.com/puzzletech/projeto-teste#readme",
"devDependencies": {
"gulp": "^4.0.2",
"gulp-autoprefixer": "^7.0.1",
"gulp-clean": "^0.4.0",
"gulp-clean-css": "^4.3.0",
"gulp-htmlmin": "^5.0.1",
"gulp-imagemin": "^7.1.0",
"gulp-rev": "^9.0.0",
"gulp-uglify": "^3.0.2",
"gulp-usemin": "^0.3.30",
"gulp-useref": "^4.0.1"
}
}
Segue o detalhamento do erro que estou recebendo:
Using gulpfile ~/Documents/xampp/www/projeto-teste/gulpfile.js
[11:35:28] Starting 'default'...
[11:35:28] Starting 'clean'...
[11:35:28] Finished 'clean' after 38 ms
[11:35:28] Starting 'copy'...
[11:35:29] Finished 'copy' after 234 ms
[11:35:29] Starting 'minif-html'...
[11:35:29] Starting 'build-img'...
[11:35:31] 'minif-html' errored after 2.21 s
[11:35:31] Error: write after end
at writeAfterEnd (/Users/renotavares/Documents/xampp/www/projeto-teste/node_modules/readable-stream/lib/_stream_writable.js:288:12)
at DestroyableTransform.Writable.write (/Users/renotavares/Documents/xampp/www/projeto-teste/node_modules/readable-stream/lib/_stream_writable.js:332:20)
at DestroyableTransform.ondata (/Users/renotavares/Documents/xampp/www/projeto-teste/node_modules/readable-stream/lib/_stream_readable.js:619:20)
at DestroyableTransform.emit (events.js:315:20)
at DestroyableTransform.EventEmitter.emit (domain.js:506:15)
at addChunk (/Users/renotavares/Documents/xampp/www/projeto-teste/node_modules/readable-stream/lib/_stream_readable.js:291:12)
at readableAddChunk (/Users/renotavares/Documents/xampp/www/projeto-teste/node_modules/readable-stream/lib/_stream_readable.js:278:11)
at DestroyableTransform.Readable.push (/Users/renotavares/Documents/xampp/www/projeto-teste/node_modules/readable-stream/lib/_stream_readable.js:245:10)
at DestroyableTransform.Transform.push (/Users/renotavares/Documents/xampp/www/projeto-teste/node_modules/readable-stream/lib/_stream_transform.js:148:32)
at DestroyableTransform.endStream [as _flush] (/Users/renotavares/Documents/xampp/www/projeto-teste/node_modules/gulp-concat/index.js:96:10)
[11:35:31] 'default' errored after 2.49 s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! projeto-teste1.0.0 gulp: `gulp`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the projeto-teste@1.0.0 gulp script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Tentei pesquisar sobre o erro mas não encontrei nada que resolvesse.