我试图使用gulp来缩小包含JS文件的文件夹.但是,其中一个文件存在上述错误,导致其无法缩小.
我设法抓住并打印了错误,我在这里部分打印过:
JS_Parse_Error {
message: 'SyntaxError: Unexpected token: punc ())',
filename: 'ex.js',
line: 189,
col: 25,
pos: 6482,
stack: Error\n at new JS_Parse_Error (eval at <anonymous> ... )
plugin: 'gulp-uglify',
fileName: '.../js/ex.js',
showStack: false
}
Run Code Online (Sandbox Code Playgroud)
有问题的文件包含以下内容,缩写为:
function() {
...
$.confirm({
buttons: {
confirm: function() {
$.post('/ajax-handler', {
...
})
.done( function(response) {
var data = filterResponse(response);
if (data['status'] == 'success') {
sleep(1000).then(() => {
* ...
});
sleep(5000).then(() => {
...
});
} else {
console.log('Oops!');
}
})
.fail( function(err, …Run Code Online (Sandbox Code Playgroud) 我在运行此命令时遇到错误
gulp.task('minify', function () {
return gulp
.src('public/app/js/myapp.bundle.js')
.pipe(uglify())
.pipe(gulp.dest('public/app/js/myapp.bundle.min.js'));
});
Run Code Online (Sandbox Code Playgroud)
GulpUglifyError:无法缩小JavaScript引起:SyntaxError:意外的标记:name(MenuItem)(行:1628,col:18,pos:53569)
该位置的代码就是这个
setters: [],
execute: function () {
class MenuItem { // <-- line 1628
Run Code Online (Sandbox Code Playgroud)
怎么了?
我收到以下错误
解析错误:意外的令牌运算符«=»,预期的punc«,»第159行,第26列
这是我的代码
function fitBounds(type="all", shape=null) {
var bounds = new google.maps.LatLngBounds();
if ( type == "all" ){
if ((circles.length > 0) | (polygons.length > 0)){
$.each(circles, function(index, circle){
bounds.union(circle.getBounds());
});
$.each(polygons, function(index, polygon){
polygon.getPath().getArray().forEach(function(latLng){
bounds.extend(latLng);
});
});
}
}
else if ( (type == "single") && (shape != null) ) {
if (shape.type == google.maps.drawing.OverlayType.MARKER) {
marker_index = markers.indexOf(shape);
bounds.union(circles[marker_index].getBounds());
}
else {
shape.getPath().getArray().forEach(function(latLng){
bounds.extend(latLng);
});
}
}
if (bounds.isEmpty() != true)
{
map.fitBounds(bounds);
}
}
Run Code Online (Sandbox Code Playgroud)