该
on('error')事件仍被触发。但是,browserify流与其他Gulp流有点不同。在browserify的错误处理函数中,您需要显式调用this.emit("end")gulp任务示例
var browserify = require('browserify');var gulp = require('gulp');var source = require("vinyl-source-stream");var reactify = require('reactify');gulp.task('browserify', function(){ // create new bundle var b = browserify(); // add transform if you want b.transform(reactify); // add file to browserify b.add("./src/main.js"); // start bundling return b.bundle() .on('error', function(err){ // print the error (can replace with gulp-util) console.log(err.message); // end this stream this.emit('end'); }) .pipe(source('main.js')) // pipe other plugin here if you want .pipe(gulp.dest('./dist'));});错误函数处理程序可防止gulp崩溃,
this.emit("end")停止当前流,而不是让其运行到下一个管道。事件处理程序还可以捕获转换插件中的错误。有关更多信息,您可以在这里阅读http://truongtx.me/2014/07/15/handle-errors-while-using-gulp-
watch/



