运行gulp时解析错误

时间:2017-07-13 15:34:37

标签: javascript gulp

每当运行gulp来缩小JavaScript文件时,我的命令终端都会出现以下错误。我检查了下面列出的所有文件,但我似乎没有发现任何错误。错误信息如下: events.js:182       扔掉//未处理的'错误'事件       ^ 错误:解析错误:

at new HTMLParser (C:\wamp64\www\webportaluser\viewvendingAdmin\node_modules\html-minifier\src\htmlparser.js:236:13)    at minify (C:\wamp64\www\webportaluser\viewvendingAdmin\node_modules\html-minifier\src\htmlminifier.js:861:3)
at Object.exports.minify (C:\wamp64\www\webportaluser\viewvendingAdmin\node_modules\html-minifier\src\htmlminifier.js:1216:10)
at objectAssign.fileName (C:\wamp64\www\webportaluser\viewvendingAdmin\node_modules\gulp-htmlmin\index.js:22:39)
at module.exports (C:\wamp64\www\webportaluser\viewvendingAdmin\node_modules\tryit\tryit.js:8:9)
at minifyHtml (C:\wamp64\www\webportaluser\viewvendingAdmin\node_modules\gulp-htmlmin\index.js:21:9)
at Transform.htmlminTransform [as _transform] (C:\wamp64\www\webportaluser\viewvendingAdmin\node_modules\gulp-htmlmin\index.js:51:7)
at Transform._read (C:\wamp64\www\webportaluser\viewvendingAdmin\node_modules\gulp-htmlmin\node_modules\readable-stream\lib\_stream_transform.js:182:10)
at Transform._write (C:\wamp64\www\webportaluser\viewvendingAdmin\node_modules\gulp-htmlmin\node_modules\readable-stream\lib\_stream_transform.js:170:83)
at doWrite (C:\wamp64\www\webportaluser\viewvendingAdmin\node_modules\gulp-htmlmin\node_modules\readable-stream\lib\_stream_writable.js:406:64)

1 个答案:

答案 0 :(得分:1)

您可以使用以下格式查找导致错误的行。

gulp.task('scripts', ['clean'], function () {
  return gulp.src('js/*.js')
    .pipe(uglify().on('error', function(e){
        console.log(e);
     }))
    .pipe(gulp.dest('minjs'));
});