[英]Gulp.js can't compile angular.js project due to excessive js errors?
我正在嘗試從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的第二行中存在語法錯誤。
這兩個插件的反應彼此略有不同。 一種是有用的告訴您行號,另一種是有用的告訴您文件名。
既然您已經重命名了文件,似乎他們在談論已經縮小的文件,而實際上只是您過早地重命名了其內存中表示形式。
對於初學者,我建議您在縮小文件之前不要重命名該文件,因為您的錯誤令人困惑。 到那時,您可能會看到錯誤出現在保存到dist / scripts / main.js的文件中(在該文件的第二行,您顯然有一個錯誤的冒號)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.