sách gpt4 ai đã đi

Gulp.js không thể biên dịch dự án angular.js do có quá nhiều lỗi js?

In lại 作者:太空宇宙 更新时间:2023-11-03 22:37:37 27 4
mua khóa gpt4 Nike

我正在尝试从 Grunt 迁移到 Gulp。这个项目在 Grunt 下运行得很好,所以我一定是在 Gulp 中做错了什么。

除脚本外,所有其他任务均有效。我现在厌倦了添加和注释部分。

我不断收到与意外 token 相关的错误。使用毫克-分钟:

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(làm xấu đi())
.pipe(gulp.dest('dist/scripts'))
.pipe(notify({
message: 'Scripts task complete'
}));
});

1 Câu trả lời

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

这两个插件的 react 略有不同。一个是告诉您行号,另一个是告诉您文件名。

由于您已经重命名了该文件,看起来他们正在谈论一个已经缩小的文件,而实际上这只是您过早地重命名了其内存中的表示形式。

对于初学者,我建议您在缩小文件之前不要重命名该文件,因为您的错误令人困惑。此时,您可能会看到错误出现在保存到 dist/scripts/main.js 的文件中(在该文件的第二行,您显然有一个错误的冒号)。

关于node.js - 由于 js 错误过多,Gulp.js 无法编译 angular.js 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23495436/

27 4 0
太空宇宙
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com