JSMin出错

时间:2014-12-09 08:45:20

标签: javascript php laravel gulp jsmin

在下面运行gulp任务时,我从JSmin获得以下错误消息:

/var/www/html/a/node_modules/gulp-jsmin/node_modules/jsmin-sourcemap/node_modules/jsmin2/lib/jsmin.c.index.js:40
          stream.write(str);
                 ^
TypeError: Object function (err) {
          // Add the error to output
          options.error += err;
        } has no method 'write'
    at fputs (/var/www/html/a/node_modules/gulp-jsmin/node_modules/jsmin-sourcemap/node_modules/jsmin2/lib/jsmin.c.index.js:40:18)
    at error (/var/www/html/a/node_modules/gulp-jsmin/node_modules/jsmin-sourcemap/node_modules/jsmin2/lib/jsmin.c.index.js:89:9)
    at action (/var/www/html/a/node_modules/gulp-jsmin/node_modules/jsmin-sourcemap/node_modules/jsmin2/lib/jsmin.c.index.js:218:25)
    at jsmin (/var/www/html/a/node_modules/gulp-jsmin/node_modules/jsmin-sourcemap/node_modules/jsmin2/lib/jsmin.c.index.js:352:21)
    at main (/var/www/html/a/node_modules/gulp-jsmin/node_modules/jsmin-sourcemap/node_modules/jsmin2/lib/jsmin.c.index.js:368:9)
    at jsminFn (/var/www/html/a/node_modules/gulp-jsmin/node_modules/jsmin-sourcemap/node_modules/jsmin2/lib/jsmin.c.index.js:373:12)
    at jsmin (/var/www/html/a/node_modules/gulp-jsmin/node_modules/jsmin-sourcemap/node_modules/jsmin2/lib/jsmin.js:82:3)
    at Object.Collector.addFile (/var/www/html/a/node_modules/gulp-jsmin/node_modules/jsmin-sourcemap/lib/jsmin.sourcemap.js:24:19)
    at Array.forEach (native)
    at module.exports (/var/www/html/a/node_modules/gulp-jsmin/node_modules/jsmin-sourcemap/lib/jsmin.sourcemap.js:136:9)

/ ** Gulp任务** /

gulp.task('js', function() {
    gulp.src('app/assets/javascripts/**/*.js')
        .pipe(changed('public/assets/javascripts/min'))
        .pipe(jsmin())
        .pipe(rename({suffix: '.min'}))
        .pipe(gulp.dest('public/assets/javascripts/min'));

    gulp.src([  'public/assets/javascripts/min/bootstrap.min.js','public/assets/javascripts/min/jquery.flexslider.min.js','public/assets/javascripts/min/waypoints.min.min.js',
            'public/assets/javascripts/min/modernizr.custom.min.js','public/assets/javascripts/min/jquery.stapel.min.js', 'public/assets/javascripts/min/jquery.socialist.min.js',
            'public/assets/javascripts/min/enscroll.min.min.js','public/assets/javascripts/min/jquery-ui-1.8.2.custom.min.min.js','public/assets/javascripts/min/pirobox_extended_min.min.js',
            'public/assets/javascripts/min/jquery.masonry.min.min.js', 'public/assets/javascripts/min/functions.min.js'])
        .pipe(concat('application.js'))
        .pipe(gulp.dest('public/assets/javascripts/min/'));
});

有人可以帮我弄清楚发生了什么吗?

1 个答案:

答案 0 :(得分:0)

简短的回答是node-jsmin2模块中有一个错误,自修订版7d5f486f46b453d738057e97060e4805846bf4af以来引入。

在该修订版中,fputs已修改为调用stream.write(str)而不是stream(str)stdout被修改为包含write和{{{的对象1}}方法 - 但writeFromIndex未进行类似修改。 (该提交,BTW,意味着stderrstdout的默认值,即stderrconsole.log不再适合。{{{{ 1}}更改提交。)

这是一个快速的“修复”(我打算发送拉取请求,但决定反对):

console.error