Ugly consequences arise as Gulp stumbles upon uncharted territory during the uglify

I'm experiencing an issue with my squish-jquery task. Every time I run it, I encounter the following error:

Starting 'squish-jquery'...

events.js:85
      throw er; // Unhandled 'error' event
            ^
Error
    at new JS_Parse_Error (/Users/shill7/Documents/socialprojects/social-ops-dashboard-angular/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:196:18)
    at js_error (/Users/shill7/Documents/socialprojects/social-ops-dashboard-angular/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:204:11)
    at croak (/Users/shill7/Documents/socialprojects/social-ops-dashboard-angular/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:679:41)
    at token_error (/Users/shill7/Documents/socialprojects/social-ops-dashboard-angular/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:683:9)
    at expect_token (/Users/shill7/Documents/socialprojects/social-ops-dashboard-angular/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:696:9)
    at expect (/Users/shill7/Documents/socialprojects/social-ops-dashboard-angular/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:699:36)
    at function_ (/Users/shill7/Documents/socialprojects/social-ops-dashboard-angular/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:959:9)
    at expr_atom (/Users/shill7/Documents/socialprojects/social-ops-dashboard-angular/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1188:24)
    at maybe_unary (/Users/shill7/Documents/socialprojects/social-ops-dashboard-angular/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1358:19)
    at expr_ops (/Users/shill7/Documents/socialprojects/social-ops-dashboard-angular/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1393:24)

I have tried to find a solution for this error, but unfortunately, I haven't been able to find any relevant information. I'm not sure if the issue lies with my setup or with Uglify itself. Here is the code from my gulpfile.js:

    // Load Gulp
var gulp    = require('gulp'),
    gutil   = require('gulp-util');
    plugins = require('gulp-load-plugins')();

var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var ignore = require('gulp-ignore');

// Start Watching: Run "gulp"
gulp.task('default', ['watch']);

// Minify jQuery Plugins: Run manually with: "gulp squish-jquery"
gulp.task('squish-jquery', function() {
  return gulp.src(['src/bower_components/**/*.js', '!src/bower_components/**/*.min.js'])
    .pipe(ignore.exclude([ "**/*.map" ]))
    .pipe(plugins.uglify())
    .pipe(plugins.concat('jquery.plugins.min.js'))
    .pipe(gulp.dest('build')).on('error', gutil.log);
});

// Minify Custom JS: Run manually with: "gulp build-js"
gulp.task('build-js', function() {
  return gulp.src(['src/js/**/*.js', 'src/js/components-controllers/*.js'])
    .pipe(plugins.jshint())
    .pipe(plugins.jshint.reporter('jshint-stylish'))
    .pipe(plugins.uglify())
    .pipe(plugins.concat('scripts.min.js'))
    .pipe(gulp.dest('build'));
});

// Less to CSS: Run manually with: "gulp build-css"
gulp.task('build-css', function() {
    return gulp.src('src/less/all.less')
        .pipe(plugins.plumber())
        .pipe(plugins.less())
        .on('error', function (err) {
            gutil.log(err);
            this.emit('end');
        })
        .pipe(plugins.autoprefixer(
            {
                browsers: [
                    '> 1%',
                    'last 2 versions',
                    'firefox >= 4',
                    'safari 7',
                    'safari 8',
                    'IE 8',
                    'IE 9',
                    'IE 10',
                    'IE 11'
                ],
                cascade: false
            }
        ))
        .pipe(plugins.cssmin())
        .pipe(gulp.dest('build')).on('error', gutil.log);
});

//Image minification
gulp.task('imagemin', function() {
    return gulp.src('src/images/*')
        .pipe(imagemin({
            progressive: true,
            svgoPlugins: [{removeViewBox: false}],
            use: [pngquant()]
        }))
        .pipe(gulp.dest('build/images'));
});

// Default task
gulp.task('watch', function() {
    gulp.watch('src/bower_components/**/*.js', ['squish-jquery']);
    gulp.watch('src/js/**.js', ['build-js']);
    gulp.watch('src/images/*', ['imagemin']);
    gulp.watch('src/less/**/*.less', ['build-css']);
});

Answer №1

As previously mentioned, it would be advisable to enable error logging for the uglify plugin in order to identify the precise location of the error:

//....
.pipe(uglify())
.on('error', function(){
  //take necessary actions here
})
//....

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for applying an active class to buttons using ng-click?

Here is the HTML code for the buttons. The taskfilter is the filter that controls how the buttons work when clicked and the class name is 'sel' <a class="clear-completed" ng-click="taskfilter = 1" ng-class="{'sel':enabled}"> &l ...

Using Rails' link_to method within Bootstrap modals

I'm trying to implement a voting system where users can vote on different items displayed in a Bootstrap modal. Each item is listed as a button on the index page, and when clicked, it opens up the modal for voting. However, I'm facing challenges ...

Utilizing NPM Package Configuration Variables with Docker Commands: A Guide

I have a unique file structure where my package.json contains a single variable called settings which defines the port for the application: package.json ... "settings":{ "port": "3000" }, ... In addition, I've set up a custom script to execute a ...

Steps to initiate my selenium-standalone server: Execute the command "selenium-standalone start"

I'm currently facing a challenge while trying to execute a test script in WebDriverIO. After cloning the code from wdio-cucumber-framework, I am unable to get selenium-standalone to start properly. The error message indicates an issue with geckodriv ...

Exploring the concept of returning objects in jQuery

I'm really trying to grasp the inner workings of how jQuery creates the return object when searching for DOM elements. I've delved into the source code, but I must admit that it's not entirely clear to me yet. So, I'm reaching out here ...

Tips for adding an additional div inside a navigation container, evenly spacing objects, and aligning the search bar to the right

I'm currently working on designing a simple navigation bar but I'm facing difficulties in aligning the elements correctly. See my progress here: https://jsfiddle.net/zigzag/bL1jxfax/ Here are my objectives: 1) Ensure that the navigation bar rea ...

Retrieve the nearest attribute from a radio button when using JQuery on a click event

I have a query regarding the usage of JS / JQuery to extract the data-product-name from a selected radio button, prior to any form submission. Although my attempt at code implementation seems incorrect: return jQuery({{Click Element}}).closest("form" ...

Transmit information using JSON format in Angular 8 using FormData

i am struggling with sending data to the server in a specific format: { "name":"kianoush", "userName":"kia9372", "email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bcd7d5ddd8ce85...@example.com</a>" } H ...

When utilizing jQuery.ajax() for JSONP, if a parse error occurs, the error callback will be triggered instead of the success callback despite receiving a status

Initially, I have reviewed similar posts on the website but none of them have resolved my issue. My requirement is to fetch a JSON file from a web server. The JSON file has been validated by JSONLint, ensuring the syntax is correct. The data in JSON forma ...

Trouble with the filter function in the component array

I am facing an issue with creating and deleting multiple components. I have successfully created the components, but for some reason, I am unable to delete them when I click on the "delete" button. state = { data: '', todoCard: [], id ...

Access array information using AngularJS

Sorry for any language issues. I am trying to figure out how to extract an array data from AngularJS in order to save it using Node.js. This is my AngularJS script: angular.module('myAddList', []) .controller('myAddListController&apos ...

transferring information from Node.js/MongoDB to the front-end (invisible in the browser)

I am trying to retrieve data from a mongodb database and pass it to the front-end. The function I have written works in the console, where I can see an array containing elements. However, when I try to view it in the browser, it shows undefined. I am worki ...

Link that updates periodically linked to an image

My goal is to have a URL change on a timer that is linked to an image. For example, after 10 seconds, I want the URL attached to the image to change without changing the actual image itself. I've been trying to figure out how to modify this code, but ...

The AngularJS templates' use of the ternary operator

Is there a way to implement a ternary operation in AngularJS templates? I am looking for a way to apply conditionals directly in HTML attributes such as classes and styles, without having to create a separate function in the controller. Any suggestions wo ...

Ways to prevent the input value from rising on a number type input when the up button is pressed

I'm curious about whether it's possible to prevent the input value from increasing when I press the up button on a type number input. Any ideas? ...

Using AngularJS date picker to set value in Spring model setter

When using AngularJS with Spring, I noticed a discrepancy in the date values between my view file and the POJO User object. In my view file, I have used an input type date to bind the "user.dateOfBirth" attribute. When I select a date, it is displayed cor ...

Issues with splicing an Angular array using pure JavaScript

Could someone please help me figure out what I'm doing incorrectly? I have some JSON data that I am converting into an array for use in an ng-repeat. Before looping through the array, I am checking the event dates against today's date and removin ...

Unable to retrieve the value from the selected radio button

Below is the provided HTML: <form> <div class="form-group"> <div class="checkbox-detailed male_input"> <input type="radio" name="gender" id="male" value="male"> <label for="male"> ...

Tips for resolving an issue with mongoose Model.create becoming unresponsive indefinitely

I'm having trouble understanding why my mongoose Model.create operation isn't completing successfully. The same connection is working well with other controller functions. vscode postman I am attempting to create a new document, but my code s ...

Tips for saving the file path locally using local storage in AngularJS

My attempt at using $localstorage to store the file path locally and preview it using an iframe is resulting in an error. $scope.getResume = function() { var resumeJson = { "json":{ "request":{ ...