Gulp.js无法编译angular.js项目由于过多的js错误?

我正尝试从Grunt转移到Gulp。 这个项目在Grunt下运行良好,所以我一定在Gulp做错了。

除脚本外,其他任务都可以工作。 现在我已经厌倦了添加和注释部分。

我不断收到有关意外令牌的错误。 使用mg-min:

stream.js:94 throw er; // Unhandled stream error in pipe. ^ Error: Line 2: Unexpected token : at throwError (/Users/stevelombardi/Documents/dsg/node_modules/gulp-ngmin/node_modules/ngmin/node_modules/esprima/esprima.js:1156:21) 

用ng-min注释掉并使用uglify(默认):

 Error caught from uglify: Unexpected token: punc (:) in /Users/stevelombardi/Documents/dsg/dist/scripts/main.min.js. Returning unminifed code [gulp] gulp-notify: [Gulp notification] Scripts task complete [gulp] Finished 'scripts' after 2.97 s 

我很难过 这是任务:

 // Scripts gulp.task('scripts', function() { return gulp.src([ "bower_components/jquery/jquery.js", "bower_components/angular/angular.js", "bower_components/bootstrap/dist/js/bootstrap.js", "bower_components/modernizr/modernizr.js", "bower_components/angular-resource/angular-resource.js", "bower_components/angular-cookies/angular-cookies.js", "bower_components/angular-sanitize/angular-sanitize.js", "bower_components/angular-route/angular-route.js", "bower_components/jquery.easy-pie-chart/dist/angular.easypiechart.js", "bower_components/angular-bootstrap/ui-bootstrap.min.js", "bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js", "bower_components/kapusta-jquery.sparkline/dist/jquery.sparkline.js", "bower_components/leaflet-dist/leaflet.js", "bower_components/angular-leaflet/dist/angular-leaflet-directive.js", "bower_components/ngprogress/build/ngProgress.js", "bower_components/angular-bootstrap-toggle-switch/angular-toggle-switch.js", "bower_components/flot/jquery.flot.js", "bower_components/flot/jquery.flot.resize.js", "bower_components/flot.tooltip/js/jquery.flot.tooltip.js", "bower_components/angular-flot/angular-flot.js", 'src/scripts/**/*.js', ]) .pipe(jshint('.jshintrc')) .pipe(jshint.reporter('default')) // .pipe(ngmin({ // dynamic: false // })) // .pipe(gulp.dest('dist/scripts')) .pipe(concat('main.js')) .pipe(gulp.dest('dist/scripts')) .pipe(rename({ suffix: '.min' })) .pipe(uglify()) .pipe(gulp.dest('dist/scripts')) .pipe(notify({ message: 'Scripts task complete' })); }); 

我认为可以肯定地说,来自两个插件的输出可以用来表示在传递给ngmin或uglify的行的第二行有语法错误。

这两个插件只是反应有点不同。 一个是帮忙告诉你行号,另一个是帮忙告诉你文件名。

既然你已经重命名了这个文件,好像他们正在讨论一个已经被缩小的文件,实际上它只是提前重命名了它的内存表示。

对于初学者,我build议不要重命名文件,直到你缩小了它,因为你的错误是混乱的。 在这一点上,你可能会发现错误出现在保存到dist / scripts / main.js的文件中(在那个文件的第二行,你显然有一个错误的冒号)。

Interesting Posts