gpt4 book ai didi

gulp - gulp-uglify events.js未处理的“错误”事件

转载 作者:行者123 更新时间:2023-12-03 23:19:05 25 4
gpt4 key购买 nike

我收到此错误。昨天运行gulp可以正常工作,但是今天早上(更改了NO代码),我遇到了这个错误。

$ gulp
[08:54:10] Using gulpfile C:\Source\Source2\bunny-meadows\gulpfile.js
[08:54:10] Starting 'scripts'...
[08:54:10] 'scripts' errored after 11 ms
[08:54:10] TypeError: listener must be a function
at TypeError (<anonymous>)
at DestroyableTransform.addListener (events.js:130:11)
at DestroyableTransform.Readable.on (C:\Source\Source2\bunny-meadows\node_mo
dules\gulp-uglify\node_modules\through2\node_modules\readable-stream\lib\_stream
_readable.js:729:33)
at Gulp.<anonymous> (C:\Source\Source2\bunny-meadows\gulpfile.js:37:10)
at module.exports (C:\Source\Source2\bunny-meadows\node_modules\gulp\node_mo
dules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (C:\Source\Source2\bunny-meadows\node_modules\
gulp\node_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (C:\Source\Source2\bunny-meadows\node_modules\
gulp\node_modules\orchestrator\index.js:214:10)
at Gulp.Orchestrator.start (C:\Source\Source2\bunny-meadows\node_modules\gul
p\node_modules\orchestrator\index.js:134:8)
at c:\Users\hschillig.SCDL\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js
:129:20
at process._tickCallback (node.js:419:13)

events.js:72
throw er; // Unhandled 'error' event
^
Error
at new JS_Parse_Error (C:\Source\Source2\bunny-meadows\node_modules\gulp-ugl
ify\node_modules\uglify-js\lib\parse.js:196:18)
at js_error (C:\Source\Source2\bunny-meadows\node_modules\gulp-uglify\node_m
odules\uglify-js\lib\parse.js:204:11)
at croak (C:\Source\Source2\bunny-meadows\node_modules\gulp-uglify\node_modu
les\uglify-js\lib\parse.js:675:9)
at token_error (C:\Source\Source2\bunny-meadows\node_modules\gulp-uglify\nod
e_modules\uglify-js\lib\parse.js:683:9)
at expect_token (C:\Source\Source2\bunny-meadows\node_modules\gulp-uglify\no
de_modules\uglify-js\lib\parse.js:696:9)
at expect (C:\Source\Source2\bunny-meadows\node_modules\gulp-uglify\node_mod
ules\uglify-js\lib\parse.js:699:36)
at function_ (C:\Source\Source2\bunny-meadows\node_modules\gulp-uglify\node_
modules\uglify-js\lib\parse.js:959:9)
at expr_atom (C:\Source\Source2\bunny-meadows\node_modules\gulp-uglify\node_
modules\uglify-js\lib\parse.js:1188:24)
at maybe_unary (C:\Source\Source2\bunny-meadows\node_modules\gulp-uglify\nod
e_modules\uglify-js\lib\parse.js:1358:19)
at expr_ops (C:\Source\Source2\bunny-meadows\node_modules\gulp-uglify\node_m
odules\uglify-js\lib\parse.js:1393:24)
at maybe_conditional (C:\Source\Source2\bunny-meadows\node_modules\gulp-ugli
fy\node_modules\uglify-js\lib\parse.js:1398:20)
at maybe_assign (C:\Source\Source2\bunny-meadows\node_modules\gulp-uglify\no
de_modules\uglify-js\lib\parse.js:1422:20)


我的gulpfile.js看起来像这样:

var gulp = require('gulp');

// Include Our Plugins
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var livereload = require('gulp-livereload');

var paths = {
// using framework version of jquery
scripts: [
'public/assets/js/jquery.min.js',
'public/assets/plugins/mustachejs/mustache.js',
'public/assets/js/modernizr.js',
'public/assets/js/bootstrap.min.js',
'public/assets/js/placeholders.min.js',
'public/assets/plugins/bootstrap-wysiwyg/bootstrap3-wysihtml5.all.min.js',
'public/assets/plugins/bootstrap-wysiwyg/bootstrap3-wysihtml5.min.js',
'public/assets/plugins/responsiveslides/responsiveslides.min.js',
'public/assets/plugins/bxslider/jquery.bxslider.min.js',
'public/assets/plugins/magnific-popup/magnific-popup.js',
'public/assets/js/jquery.autocomplete.min.js',
'public/assets/js/plugins/additems.js',
'public/assets/js/plugins/farm/farm.js',
'public/assets/js/plugins/plusminus.js',
'public/assets/js/core.js'
]
};

// Concatenate & Minify JS
gulp.task('scripts', function() {
return gulp.src(paths.scripts)
.pipe(concat('all.js'))
.pipe(gulp.dest('public/assets/js'))
.pipe(rename('all.min.js'))
.pipe(uglify())
.on('error')
.pipe(gulp.dest('public/assets/js'))
.pipe(livereload());
});

// Watch Files For Changes
gulp.task('watch', function() {
livereload.listen();
gulp.watch(paths.scripts, ['scripts']);
});

// Default Task
gulp.task('default', ['scripts', 'watch']);


再一次,我什么都没做,所以我不明白为什么今天早上突然间它不想工作。

最佳答案

遵循此帮助:


安装Gulp-util
使用以下语句导入Gulp-util:var gutil = require('gulp-util');
最后,在对代码进行丑陋处理时,按如下所示附加错误处理程序:.pipe(uglify().on('error', gutil.log))


我能够调试它。这是我包含的其中一个缩小文件中的一个语法错误。

关于gulp - gulp-uglify events.js未处理的“错误”事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31003457/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com