question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

gulp-babel make gulp crash when their is an error on source

my source:

var i = 5:

error:

[15:50:28] Starting 'babel'...
[15:50:28] Finished 'babel' after 111 ms

events.js:125
      throw er; // Unhandled 'error' event
            ^
SyntaxError: C:/wamp/www/src/js/test.js: Unexpected token (1:9)
> 1  | ←[36mvar←[39m ←[37ma←[39m ←[1m←[37m=←[39m←[22m ←[35m5←[39m←[1m←[37m:←[39m←[22m

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

24reactions
darkbaby123commented, Jul 31, 2015

I found there’s no need to modify the plugin. Just add this.emit('end') on error handler and it works.

Below is my whole task:

gulp.task('babel', ['babelPolyfill'], function(done) {
  gulp.src(paths.js)
    .pipe(sourcemaps.init())
    .pipe(babel())
    .on('error', function(e) {
      console.log('>>> ERROR', e);
      // emit here
      this.emit('end');
    })
    .pipe(concat('all.js'))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./www/app/'))
    .on('end', done);
});
15reactions
octrefcommented, Feb 3, 2016

The method originally posted by @sindresorhus doesn’t work if you are watching for recompilation. After a compilation error the watch will not keep recompiling even if you fixed your code.

gulp-plumber solves the problem for me:

gulp.task('babel', () => {
  return gulp.src('src/**/*.js')
    .pipe(plumber())
    .pipe(babel({
      presets: ['es2015']
    }))
    .on('error', (err) => {
      gutil.log(gutil.colors.red('[Compilation Error]'));
      gutil.log(gutil.colors.red(err.message));
    })
    .pipe(gulp.dest('dist'));
});

Read more comments on GitHub >

github_iconTop Results From Across the Web

The complete guide to error monitoring and crash reporting
Let's start with the terminology. In a classical sense, an error means something went wrong, while a crash means that it went so...
Read more >
Crash: Com Error in QuickBooks Desktop
While you open, work, or send forms in your QuickBooks, you may get this error message: Crash: Com Error. Don't worry, we can...
Read more >
Understanding the exception types in a crash report
Learn what the exception type tells you about why your app crashed. ... the error in the Additional Diagnostic Information section of the...
Read more >
Let It Crash: Best Practices for Handling Node.js Errors on ...
If a crash occurs, log as much relevant information as possible, including the errors and stack trace. Rely on libraries like pino or...
Read more >
5 Troubleshoot System Crashes
A crash, or fatal error, causes a process to terminate abnormally. There are various possible reasons for a crash. For example, a crash...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found