tmaximini / generator-ionic-gulp

A Yeoman generator for fast hybrid app development that stays out of your way
134 stars 36 forks source link

Unable to use angular-img-fallback bower module. #41

Open an-rahulpandey opened 7 years ago

an-rahulpandey commented 7 years ago

Hi,

I am getting JS Parse error message after installing the angular module the https://github.com/dcohenb/angular-img-fallback

Error
    at new JS_Parse_Error (/Users/rahul/Desktop/demo/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1534:18)
    at js_error (eval at <anonymous> (/Users/rahul/Desktop/demo/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1542:11)
    at croak (eval at <anonymous> (/Users/rahul/Desktop/demo/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2089:9)
    at token_error (eval at <anonymous> (/Users/rahul/Desktop/demo/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2097:9)
    at unexpected (eval at <anonymous> (/Users/rahul/Desktop/demo/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2103:9)
    at expr_atom (eval at <anonymous> (/Users/rahul/Desktop/demo/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2630:9)
    at maybe_unary (eval at <anonymous> (/Users/rahul/Desktop/demo/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2792:19)
    at expr_ops (eval at <anonymous> (/Users/rahul/Desktop/demo/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2827:24)
    at maybe_conditional (eval at <anonymous> (/Users/rahul/Desktop/demo/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2832:20)
    at maybe_assign (eval at <anonymous> (/Users/rahul/Desktop/demo/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2856:20)
    at maybe_assign (eval at <anonymous> (/Users/rahul/Desktop/demo/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2864:32)
    at expression (eval at <anonymous> (/Users/rahul/Desktop/demo/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2875:20)
    at expr_list (eval at <anonymous> (/Users/rahul/Desktop/demo/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2641:24)
    at eval (eval at <anonymous> (/Users/rahul/Desktop/demo/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2651:23)
    at eval (eval at <anonymous> (/Users/rahul/Desktop/demo/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2136:24)
    at expr_atom (eval at <anonymous> (/Users/rahul/Desktop/demo/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2614:35)

Library Versions -

├─┬ gulp-uglify@1.5.4
│ ├── deap@1.0.0
│ ├─┬ isobject@2.1.0
│ │ └── isarray@1.0.0
│ ├─┬ uglify-js@2.6.4
│ │ ├── async@0.2.10
│ │ ├── uglify-to-browserify@1.0.2
│ │ └─┬ yargs@3.10.0
│ │   ├── camelcase@1.2.1
│ │   ├─┬ cliui@2.1.0
│ │   │ ├─┬ center-align@0.1.3
│ │   │ │ ├─┬ align-text@0.1.4
│ │   │ │ │ └── longest@1.0.1
│ │   │ │ └── lazy-cache@1.0.4
│ │   │ ├── right-align@0.1.3
│ │   │ └── wordwrap@0.0.2
│ │   └── window-size@0.1.0
│ └── uglify-save-license@0.4.1
an-rahulpandey commented 7 years ago

Moreover, if I just add the uncompressed js file in my scripts folder, I get the same JS Parse Error. However, if I add the minified file in my scripts folder, then it doesn't give any error.

tmaximini commented 7 years ago

I just published version 1.5.1 of the generator with updated wiredep - it worked for me without issues to add angular-img-fallback - please try this latest version. you should add this script via bower install angular-img-fallback --save not manually.

an-rahulpandey commented 7 years ago

I just reinstalled the generator and created a demo project, but still getting the same error.

snip

tmaximini commented 7 years ago

the output you posted is unrelated, it just showed all the installed npm modules. I edited that to keep this issue readable. which node.js version are you on?

an-rahulpandey commented 7 years ago

Node version is 4.4.5.

tmaximini commented 7 years ago

try commenting out the uglify part in the vendor task in your generated gulpfile.js around line 193.

gulp.task('vendor', function() {
  var vendorFiles = wiredep().js;

  return gulp.src(vendorFiles)
    .pipe(plugins.concat('vendor.js'))
    //.pipe(plugins.if(build, plugins.uglify()))
    .pipe(plugins.if(build, plugins.rev()))

    .pipe(gulp.dest(targetDir))

    .on('error', errorHandler);
});

Let's see if that helps, from your initial error message it looks like the error is connected to the uglification.

an-rahulpandey commented 7 years ago

Yes, commenting out that line works.

tmaximini commented 7 years ago

how did you install that library? It works for me if I install it via bower. Maybe you added the already minified version manually and so the uglify job breaks?

an-rahulpandey commented 7 years ago

I also installed it via bower bower install angular-img-fallback --save

tmaximini commented 7 years ago

you might try updating gulp-uglify in your package.json