简体   繁体   中英

Gulp - throw er; // Unhandled 'error' event

gulp-htmlmin throwing err like

events.js:183
  throw er; // Unhandled 'error' event
  ^
Error: Parse Error: <!-- END PAGE CONTENT WRAPPER

This same code work with other project but when I'm running gulp it is throwing error like this. How can I resove this.

here, my gulp file code

let gulp = require('gulp');
let htmlmin = require('gulp-htmlmin');

//Pages
gulp.task('pages', function () {
    gulp.src(['./src/**/*html'])
        .pipe(htmlmin({
            collapseWhitespace: true,
            removeComments: true
        }))
        .pipe(gulp.dest('./public'));
});

gulp.task('default', ['pages']);

Can anyone help?

Thanks in advance.

If the code is working on other machines it's usually either:

  • One of the gulp dependencies doesn't work with your version of node. Type node -v into your terminal and compare that with your coworkers. I'd recommend the LTS version of node as it's the most stable

  • Somewhere down the line your node_modules became corrupt. Try deleting the entire node_modules directory and run npm install

Thank you all for comments and answer.

I got the solution. I've re-install all node modules (as per Joe Rushton 's suggestion) and add gulp-util module to track error. I've found <!-- END PAGE CONTENT WRAPPER is unfinished comment in HTML file, it should be like <!-- END PAGE CONTENT WRAPPER --> .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM