我收到这个错误。昨天运行 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']);
同样,我没有改变任何东西,所以我不明白为什么今天早上它突然不想工作了。