Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

it did not throw detail information when error occurs #50

Closed
xiaoji121 opened this issue Aug 13, 2014 · 19 comments
Closed

it did not throw detail information when error occurs #50

xiaoji121 opened this issue Aug 13, 2014 · 19 comments

Comments

@xiaoji121
Copy link

when js has syntax error, this plugin output nothing but error stack.

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error
    at new JS_Parse_Error (/Users/dongming/dev/gitlab/wrench/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:189:18)
    at js_error (/Users/dongming/dev/gitlab/wrench/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:197:11)
    at croak (/Users/dongming/dev/gitlab/wrench/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:656:9)
    at token_error (/Users/dongming/dev/gitlab/wrench/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:664:9)
    at unexpected (/Users/dongming/dev/gitlab/wrench/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:670:9)
    at /Users/dongming/dev/gitlab/wrench/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:754:17
    at /Users/dongming/dev/gitlab/wrench/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:703:24
    at block_ (/Users/dongming/dev/gitlab/wrench/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:977:20)
    at ctor.body (/Users/dongming/dev/gitlab/wrench/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:950:25)
    at function_ (/Users/dongming/dev/gitlab/wrench/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:955:15)
@terinjokes
Copy link
Owner

What version of gulp-uglify and what version of gulp? We've been providing what file failed as part of the error for a while now.

@rhys-vdw
Copy link

Same problem here:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error
    at new JS_Parse_Error (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:189:18)
    at js_error (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:197:11)
    at croak (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:656:9)
    at token_error (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:664:9)
    at unexpected (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:670:9)
    at semicolon (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:690:43)
    at simple_statement (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:864:73)
    at /Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:737:19
    at /Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:703:24
    at /Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1438:23

gulp 3.8.7
gulp-uglify 0.3.1

@rhys-vdw
Copy link

Should note that I'm not convinced that a syntax error is causing this error. I'm only using popular libraries and coffeescript output for my source files.

I might try narrowing down the problem... Is there any way to get some more debug info from the module?

@terinjokes
Copy link
Owner

gulp-uglify provides detailed information on the error message, via the "fileName", and "lineNumber" properties.

Please attach an error handler to the stream.

@rhys-vdw
Copy link

Okay, definitely my fault, I was accidentally streaming a css file into uglify. 😊

@terinjokes
Copy link
Owner

Providing a better documentation on gulp error management is being tracked in gulpjs/gulp#359.

@devdattaT
Copy link

For others like me, who do not know how to get the error message, here is what you need to do:

  1. Install Gulp-util
  2. import the Gulp-util by using the following statement: var gutil = require('gulp-util');
  3. Finally, when you are uglifying the code, attach the error handler like this: .pipe(uglify().on('error', gutil.log))

@plaimanus
Copy link

I had the same problem too, Thank to @devdattaTpoined out how to show an error while compiling gulp uglify. I found out that one of mine .js files has an typo or it spits out an error. Thank you so much

check your .js files

@jpaulobneto
Copy link

@devdattaT Thanks for share this gulp-util log

@ai
Copy link

ai commented Feb 9, 2015

Why not add this info to README.md?

@ghost
Copy link

ghost commented Feb 18, 2015

Thanks, solved my issue as well.

@AliMD
Copy link

AliMD commented Mar 12, 2015

please update your read me

@terinjokes
Copy link
Owner

@AliMD The README on the 1.2.0 branch contains some documentation on errors.

@mprandot
Copy link

mprandot commented Apr 27, 2016

hello!

I use elixir + gulp, and i get the same error, someone can help me?
the function uglify() show ReferenceError: uglify is not defined

var elixir = require('laravel-elixir');
var gutil = require('gulp-util');

elixir(function (mix) {

    mix.browserify('Vue/main.js');

    mix.styles([
        'bootstrap.min.css',
        'plugins.css',
        'main.css',
        'themes/passion.css',
        'themes.css',
        'rbr/customrbr.css',
        'rbr/details.css',
        'rbr/forms.css'
    ], 'public/css/layout-one.css');


    mix.scripts([
        'vendor/modernizr-2.8.3.min.js',
        'vendor/jquery-2.2.0.min.js',
        'vendor/bootstrap.min.js',

        '../../../node_modules/lodash/lodash.js',
        '../../../node_modules/moment/moment.js',
        '../../../node_modules/moment/locale/pt-br.js',

        'plugins.js',
        'app.js',
        'pages/uiTables.js',

    ], 'public/js/layout-one.js').pipe(uglify().on('error', gutil.log));

    mix.copy('resources/assets/css/fonts', 'public/build/css/fonts');
    mix.copy('resources/assets/css/themes', 'public/build/css/themes');
    mix.copy('resources/assets/fonts', 'public/build/fonts');
    mix.copy('resources/assets/img', 'public/build/img');
    mix.copy('resources/assets/images', 'public/images');
    mix.copy('resources/assets/js/pages', 'public/build/js/pages');
    mix.copy('resources/assets/js/plugins', 'public/build/js/plugins');
    mix.copy('resources/assets/js/vendor', 'public/build/js/vendor');

    mix.scripts([
        'rbr/Graphics/prospectionGraphics.js'
    ], 'public/js/graphics.js');

    mix.version([
        'css/layout-one.css',
        'js/layout-one.js',
        'js/graphics.js']);

});

@terinjokes
Copy link
Owner

@mprandot Please see the README for how the use the recommended pump module instead of using those pipe functions directly. Then you'll get the better error messages this module already has.

@mprandot
Copy link

@terinjokes sorry!

I found the error, sintax error in one .js in mix.scripts

Thanks!

@mrbacay
Copy link

mrbacay commented May 27, 2016

I'm having the same problem, and I've tried what @devdattaT suggested, but it's still giving me the same information. It stops at the error on events.js.

Do I have to pass the error event to gutil.log?

@whoan
Copy link

whoan commented Jul 2, 2016

The fastest solution I've found was to capture the error with this:

process.on('uncaughtException', function(error) {
    console.log(error);
    process.exit(1)
})

I put that snippet in my gulpfile.js and I could figure it out where was the problem. It was a problem in my code.

@terinjokes
Copy link
Owner

If you use pump like the examples in the readme, errors will be
propagated to Gulp, which will format the errors correctly.
On Jul 2, 2016 3:09 PM, "Juan Eugenio Abadie" [email protected]
wrote:

The fastest solution I've found was to capture the error with this:

process.on('uncaughtException', function(error) {
console.log(error);
process.exit(1)
})

I put that snippet in my gulpfile.js and I could figure it out where
was the problem. It was a problem in my code.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#50 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAQsZScwj8yK9lMtOoHzkimqzhqPtXXWks5qRsWJgaJpZM4CWv-6
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests