Exec21 Exec21 - 1 year ago 302
Javascript Question

GulpUglifyError using gulp-webpack-vs2015

I am having following error

throw er; // Unhandled 'error' event
GulpUglifyError: unable to minify JavaScript
Caused by: SyntaxError: Unexpected token: punc ({) (line: 15, col: 7, pos: 1014)
at new JS_Parse_Error (eval at <anonymous> (C:\..\node_modules\gulp-uglify\node_modules\uglify-js\tools\node.js:1:0), <anonymous>:1545:18)


"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-concat": "^2.6.0",
"gulp-less": "^3.1.0",
"gulp-sourcemaps": "^2.1.1",
"gulp-typescript": "^3.0.2",
"gulp-uglify": "^2.0.0",
"uglify-js-harmony": "^2.6.2"

After looking for answers it looks like gulp-uglify relies on UglifyJS Issue with Babel, ES6 and Uglify, thus it does not work properly. On the other hand they encourage to use uglify-js-harmony instead. But still is looking at gulp-uglify\node_modules\uglify-js. How can I force gulp to point to uglify-js-harmony instead?

Thank you

Answer Source

This issue is related with my other question Gulp error with angular2, also it is necessary to deploy only needed files, or in the above case exclude node modules folder as:


"files": [

or excluding (better only include files rather than excluding)

"exclude": [
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download