Je reçois cette erreur. Courir en avalant hier a parfaitement fonctionné, mais ce matin (changement de code NO) et cette erreur me vient.
$ 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)
Mon gulpfile.js ressemble à ceci:
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']);
Encore une fois, je n'ai rien changé, je ne comprends donc pas pourquoi tout à coup, ce matin, il ne veut pas travailler.
Suite à cela a aidé:
var gutil = require('gulp-util');
.pipe(uglify().on('error', gutil.log))
J'ai pu le déboguer. Il s'agissait d'une erreur de syntaxe dans l'un des fichiers minifiés que j'inclusais.
Le meilleur moyen de comprendre les erreurs dans un pipeline Gulp consiste à utiliser un module d'assistance, tel que pump
. Comme expliqué dans la documentation Gulp Pourquoi utiliser Pump? vous pouvez obtenir les erreurs correctes en encapsulant votre pipeline.
gulp.task('scripts', function(cb) {
pump([
gulp.src(paths.scripts),
concat('all.js'),
gulp.dest('public/assets/js'),
rename('all.min.js'),
uglify(),
gulp.dest('public/assets/js'),
livereload()
], cb);
});
La liaison d'un gestionnaire d'erreurs à la partie UglifyJS du pipeline ne vous informera pas des erreurs dans les autres, et ne signalera pas correctement une erreur au système en cours d'exécution de la tâche de Gulp.