title: Gulp - events error with gulp-uglify
body: <p>I'm working on a HTML/JS/CSS website and I use Gulp as automation tool.</p>
  
  <p>It works perfectly fine when running <code>gulp serve</code> but I receive the following errors when running <code>gulp build</code>:</p>
  
  <pre><code>[18:24:52] Using gulpfile myProject/gulpfile.js
  [18:24:52] Starting 'jshint'...
  [18:24:52] Starting 'css'...
  [18:24:52] Starting 'scripts'...
  [18:24:52] Starting 'partials'...
  [18:24:52] Starting 'images'...
  [18:24:53] Starting 'videos'...
  [18:24:53] Starting 'fonts'...
  [18:24:53] Starting 'fileinclude'...
  [18:24:53] Starting 'extras'...
  [18:24:53] Finished 'jshint' after 518 ms
  [18:24:53] all files 48.19 kB
  [18:24:53] Finished 'fileinclude' after 245 ms
  
  events.js:154
        throw er; // Unhandled 'error' event
        ^
  Error
      at new JS_Parse_Error (eval at &lt;anonymous&gt; (myProject/node_modules/uglify-js/tools/node.js:28:1), &lt;anonymous&gt;:1534:18)
      at js_error (eval at &lt;anonymous&gt; (myProject/node_modules/uglify-js/tools/node.js:28:1), &lt;anonymous&gt;:1542:11)
      at croak (eval at &lt;anonymous&gt; (myProject/node_modules/uglify-js/tools/node.js:28:1), &lt;anonymous&gt;:2089:9)
      at token_error (eval at &lt;anonymous&gt; (myProject/node_modules/uglify-js/tools/node.js:28:1), &lt;anonymous&gt;:2097:9)
      at unexpected (eval at &lt;anonymous&gt; (myProject/node_modules/uglify-js/tools/node.js:28:1), &lt;anonymous&gt;:2103:9)
      at expr_atom (eval at &lt;anonymous&gt; (myProject/node_modules/uglify-js/tools/node.js:28:1), &lt;anonymous&gt;:2618:13)
      at maybe_unary (eval at &lt;anonymous&gt; (myProject/node_modules/uglify-js/tools/node.js:28:1), &lt;anonymous&gt;:2792:19)
      at expr_ops (eval at &lt;anonymous&gt; (myProject/node_modules/uglify-js/tools/node.js:28:1), &lt;anonymous&gt;:2827:24)
      at maybe_conditional (eval at &lt;anonymous&gt; (myProject/node_modules/uglify-js/tools/node.js:28:1), &lt;anonymous&gt;:2832:20)
      at maybe_assign (eval at &lt;anonymous&gt; (myProject/node_modules/uglify-js/tools/node.js:28:1), &lt;anonymous&gt;:2856:20)
      at expression (eval at &lt;anonymous&gt; (myProject/node_modules/uglify-js/tools/node.js:28:1), &lt;anonymous&gt;:2875:20)
      at expr_atom (eval at &lt;anonymous&gt; (myProject/node_modules/uglify-js/tools/node.js:28:1), &lt;anonymous&gt;:2608:26)
      at maybe_unary (eval at &lt;anonymous&gt; (myProject/node_modules/uglify-js/tools/node.js:28:1), &lt;anonymous&gt;:2792:19)
      at expr_ops (eval at &lt;anonymous&gt; (myProject/node_modules/uglify-js/tools/node.js:28:1), &lt;anonymous&gt;:2827:24)
      at maybe_conditional (eval at &lt;anonymous&gt; (myProject/node_modules/uglify-js/tools/node.js:28:1), &lt;anonymous&gt;:2832:20)
      at maybe_assign (eval at &lt;anonymous&gt; (myProject/node_modules/uglify-js/tools/node.js:28:1), &lt;anonymous&gt;:2856:20)
  </code></pre>
  
  <p>Here is an extract of gulpfile.js: </p>
  
  <pre><code>/*global -$ */
  'use strict';
  
  var gulp = require('gulp');
  var $ = require('gulp-load-plugins')();
  var browserSync = require('browser-sync');
  var reload = browserSync.reload;
  var sass = require('gulp-ruby-sass');
  //var concat = require('gulp-concat');  
  var rename = require('gulp-rename'); 
  var gulpUtil = require('gulp-util');  
  var uglify = require('gulp-uglify');  
  
  //script paths
  var jsFiles = 'app/scripts/**/*.js',  
      jsDest = 'dist/scripts';
  
  gulp.task('scripts', function() {  
      return gulp.src(jsFiles)
          //.pipe(concat('main.js'))
          .pipe(rename('main.min.js'))
          .pipe(uglify()) // issue comes from here
          .pipe(gulp.dest(jsDest));
  });
  
  gulp.task('build', ['jshint','css', 'scripts', 'partials', 'images', 'videos', 'fonts', 'fileinclude', 'extras'], function () {
    return gulp.src('dist/**/*').pipe($.size({title: 'build', gzip: true}));
  });
  
  gulp.task('default', ['clean'], function () {
    gulp.start('build');
  });
  </code></pre>
  
  <p>As the error messages seem to be related to <code>uglify-js</code>, I tried to comment out the <code>uglify()</code> call in the <code>scripts</code> task and it compiled fine. </p>
  
  <p>Would you have any idea why this is happening? </p>