- Saved searches
- Use saved searches to filter your results more quickly
- Why unable to minify JavaScript? #281
- Why unable to minify JavaScript? #281
- Comments
- Saved searches
- Use saved searches to filter your results more quickly
- GulpUglifyError: unable to minify JavaScript #349
- GulpUglifyError: unable to minify JavaScript #349
- Comments
- GulpUglifyError:Unable to minify JavaScript
- Solution 2
- Solution 3
- Solution 4
- Solution 5
- GulpUglifyError: unable to minify JavaScript (Angular 4)
- Answer by Braylee Hughes
- Answer by Samara Delacruz
- Answer by Archie Stein
- Answer by Cecilia Morgan
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
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
Why unable to minify JavaScript? #281
Why unable to minify JavaScript? #281
Comments
Happens in my gulp task every time. There is an unhandled error event and it doesn’t say what part exactly is not minify-able? Using version 2.1.2 here
events.js:163 throw er; // Unhandled 'error' event ^ GulpUglifyError: unable to minify JavaScript at createError (/home/michael-heuberger/code/videomail-client/node_modules/gulp-uglify/lib/create-error.js:6:14) at wrapper (/home/michael-heuberger/code/videomail-client/node_modules/lodash/_createHybrid.js:87:15) at trycatch (/home/michael-heuberger/code/videomail-client/node_modules/gulp-uglify/minifier.js:26:12) at DestroyableTransform.minify [as _transform] (/home/michael-heuberger/code/videomail-client/node_modules/gulp-uglify/minifier.js:79:19) at DestroyableTransform.Transform._read (/home/michael-heuberger/code/videomail-client/node_modules/readable-stream/lib/_stream_transform.js:159:10) at DestroyableTransform.Transform._write (/home/michael-heuberger/code/videomail-client/node_modules/readable-stream/lib/_stream_transform.js:147:83) at doWrite (/home/michael-heuberger/code/videomail-client/node_modules/readable-stream/lib/_stream_writable.js:345:64) at writeOrBuffer (/home/michael-heuberger/code/videomail-client/node_modules/readable-stream/lib/_stream_writable.js:334:5) at DestroyableTransform.Writable.write (/home/michael-heuberger/code/videomail-client/node_modules/readable-stream/lib/_stream_writable.js:271:11) at Transform.ondata (_stream_readable.js:555:20) error Command failed with exit code 1.
The text was updated successfully, but these errors were encountered:
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
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
GulpUglifyError: unable to minify JavaScript #349
GulpUglifyError: unable to minify JavaScript #349
Comments
"gulp": "3.9.1", "gulp-clean-css": "2.0.12", "gulp-concat": "2.6.0", "gulp-imagemin": "3.0.3", "gulp-nodemon": "2.1.0", "gulp-rename": "1.2.2", "gulp-ruby-sass": "2.1.0", "gulp-sourcemaps": "1.6.0", "gulp-uglify": "2.0.0",
gulp.task('concat-prod', () => < return gulp.src(jsFilesArray) .pipe(concat('client.js')) .pipe(gulp.dest('assets/build/')) .pipe(uglify()) .pipe(rename('client.min.js')) .pipe(gulp.dest('assets/build/')); >);
internal/streams/legacy.js:59 throw er; // Unhandled stream error in pipe. ^ GulpUglifyError: unable to minify JavaScript at createError (/home/user/user/client/node_modules/gulp-uglify/lib/create-error.js:6:14) at wrapper (/home/user/user/client/node_modules/lodash/_createHybrid.js:87:15) at trycatch (/home/user/user/client/node_modules/gulp-uglify/minifier.js:26:12) at DestroyableTransform.minify [as _transform] (/home/user/user/client/node_modules/gulp-uglify/minifier.js:76:19) at DestroyableTransform.Transform._read (/home/user/user/client/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:159:10) at DestroyableTransform.Transform._write (/home/user/user/client/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:147:83) at doWrite (/home/user/user/client/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:313:64) at writeOrBuffer (/home/user/user/client/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:302:5) at DestroyableTransform.Writable.write (/home/user/user/client/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:241:11) at DestroyableTransform.ondata (internal/streams/legacy.js:16:26)
The text was updated successfully, but these errors were encountered:
This is a valid issue even with Pipeline enabled in v3.0.1 and should be reopened please.
const $ = require( 'gulp-load-plugins' )(); const DIST_CATALOG_DEV = 'dist/dev/proj_catalog/includes/assets' const DIST_CATALOG_SRC = 'dist/plaintext/proj_catalog/includes/assets' const DIST_CATALOG_PROD = 'dist/minified/proj_catalog/includes/assets' GULP.task( 'javascript:catalog:extra', function() < return PIPELINE( GULP.src( ['src/assets/proj_catalog/javascript/**/*.js'] ), // Concatenate streams into a single file $.concat( 'catalog-extra.js' ), $.cond( PRODUCTION, $.uglify( ) ), $.cond( PRODUCTION, $.extname( '.min.js' ) ), $.cond( PRODUCTION, GULP.dest( DIST_CATALOG_PROD + '/jscript' ) ) ); >);
This is the error message even with Pipeline:
/user/Name/folder/my-project/node_modules/readable-stream/lib/internal/streams/pipeline.js:22
if (err) throw err;
^
GulpUglifyError: unable to minify JavaScript
at createError (/user/Name/folder/my-project/node_modules/gulp-uglify/lib/create-error.js:6:14)
at apply (/user/Name/folder/my-project/node_modules/lodash/_apply.js:16:25)
at wrapper (/user/Name/folder/my-project/node_modules/lodash/_createCurry.js:41:12)
at /user/Name/folder/my-project/node_modules/gulp-uglify/lib/minify.js:55:15
at DestroyableTransform._transform (/user/Name/folder/my-project/node_modules/gulp-uglify/composer.js:12:19)
at DestroyableTransform.Transform._read (/user/Name/folder/my-project/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (/user/Name/folder/my-project/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:83)
at doWrite (/user/Name/folder/my-project/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:428:64)
at writeOrBuffer (/user/Name/folder/my-project/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:417:5)
at DestroyableTransform.Writable.write (/user/Name/folder/my-project/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:334:11)
Not particularly enlightening and after hours of debugging, I found that what triggers the fail is passing options.
So, using $.uglify( ) or similar will fail and $.uglify() will work.
Please look into this again.
Thanks
GulpUglifyError:Unable to minify JavaScript
The main error is generated when you’re using ES6 format. Use the gulp-uglify-es module instead of ‘gulp-uglify’ to overcome this error.
var uglify = require('gulp-uglify-es').default;
Note: gulp-uglify-es is no longer being maintained. You may want to use terser / gulp-terser instead:
Solution 2
To see the error in console:
var gutil = require('gulp-util'); gulp.task('concat', function() < return gulp.src('app/**/*.js') // .pipe(concat('script.js')) .pipe(uglify()) .on('error', function (err) < gutil.log(gutil.colors.red('[Error]'), err.toString()); >) .pipe(gulp.dest('./dist/')) >);
To find the exact file, with line number of error register and run this task:
var pump = require('pump'); gulp.task('uglify-error-debugging', function (cb) < pump([ gulp.src('app/**/*.js'), uglify(), gulp.dest('./dist/') ], cb); >);
Solution 3
I think the top answers here are not explaining how to get the error. The docs have a section on error handling:
gulp-uglify emits an ‘error’ event if it is unable to minify a specific file
So, just capture the error and do whatever you want with it (such as logging to console) to see the filename, line number, and additional info:
uglify().on('error', console.error)
This gives you a super helpful error!
< GulpUglifyError: unable to minify JavaScript at [stack trace]) cause: < SyntaxError: Continue not inside a loop or switch [stack trace] message: 'Continue not inside a loop or switch', filename: 'ProductForm.js', line: 301, col: 37, pos: 10331 >, plugin: 'gulp-uglify', fileName: '/asset/src/js/foo/ProductForm.js', showStack: false >
Solution 4
Have you used ES6 format in your script file? If so try ES5 now because when you do gulp-uglify it doesnt understand ES6 format as of now and after that try your code
and run the task gulp concat it will work
Solution 5
For me, it was a deprecated option «preserveComments» that generated the error (and completely crashed the script).
gulp.task('concat', function() < return gulp.src('app/**/*.js') .pipe(uglify()) .on('error', function (err) < console.log( err ) >) .pipe(gulp.dest('./dist/')) >);
GulpUglifyError: unable to minify JavaScript (Angular 4)
I found how to resolve this issue. Basically uglify doesn’t work with ES6 (right now just with ES5). For resolving this problem we need to Transpilation result to ES5 with TypeScript help, and then run minification.,I don’t know how to resolve this problem. Any ideas how to resolve this problem?, Taking a coding test tomorrow to which I probably have all the answers ,ExpressionEngine® Answers
var ts = require('gulp-typescript'); var uglify = require('gulp-uglifyjs'); . .pipe(ts(< target: "es5", allowJs: true, module: "commonjs", moduleResolution: "node" >)) .pipe(uglify())
Answer by Braylee Hughes
This is my gulp scripts:,I have a problem with uglify main bundle.js file.,After running this scripts I catch next exception:, No suggested jump to results
gulp.task("compile", () => < let tsResult = gulp.src("app/**/*.ts") .pipe(sourcemaps.init()) .pipe(tsProject()); return tsResult.js .pipe(sourcemaps.write(".", < sourceRoot: '/app' >)) .pipe(concat('bundle.js')) .pipe(gulp.dest('app/_Dist/')); >); gulp.task("minify", ["compile"], function () < return gulp.src(['app/_Dist/bundle.js']) .pipe(concat('bundle.min.js')) .pipe(plumber()) .pipe(uglify()) .on('error', function (err) < gutil.log(gutil.colors.red('[Error]'), err.toString()); >) .pipe(plumber.stop()) .pipe(gulp.dest(outputLocation)); >);
Answer by Samara Delacruz
gulp.task('compile-js', function () < // app.js is your main JS file with all your module inclusions return browserify(< extensions: ['.js', '.jsx'], entries: 'javascripts/app.js', debug: true >) .transform('babelify', < presets: ['es2015', 'react'] >) .bundle() .pipe(source('bundle.min.js')) .pipe(buffer()) .pipe(sourcemaps.init()) .pipe(uglify()) .pipe(sourcemaps.write('./maps')) .pipe(gulp.dest('dist')) .pipe(livereload()) >)
GulpUglifyError: unable to minify JavaScript
Это часть моего package.json:
"dependencies": < "animate.css": "^3.5.2", "aos": "^2.2.0", "autosize": "^4.0.0", "axios": "^0.16.2", "es6-docready": "^1.0.0", "foundation-icon-fonts": "^0.1.1", "foundation-sites": "^6.4.3", "gulp-clean-css": "^3.9.0", "gulp-cssimport": "^5.1.1", "jquery": "^3.1.1", "jquery-ui-bundle": "^1.12.1", "material-design-icons": "^3.0.1", "swiper": "^3.4.2", "vue": "^2.4.4" >, "repository": < "type": "git", "url": "[git-url-of-your-project]" >, "devDependencies": < "babel-preset-es2015": "^6.16.0", "babel-preset-react": "^6.16.0", "babelify": "^7.3.0", "browserify": "^14.3.0", "browserify-shim": "^3.8.12", "gulp": "^3.9.1", "gulp-clean-css": "^3.0.4", "gulp-clone": "^1.0.0", "gulp-concat": "^2.6.0", "gulp-concat-css": "^2.3.0", "gulp-cssimport": "^5.0.0", "gulp-foreach": "^0.1.0", "gulp-htmlmin": "^3.0.0", "gulp-less": "^3.3.2", "gulp-livereload": "^3.8.1", "gulp-sourcemaps": "^1.6.0", "gulp-uglify": "^2.1.2", "streamqueue": "^1.1.1", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0" >,
npm install --save-dev babel-preset-es2017
Я не получаю никаких ошибок во время компиляции, но я получаю эту ошибку на консоли браузера, когда я запускаю свой код в своем браузере:
Uncaught ReferenceError: regeneratorRuntime is not defined
Answer by Archie Stein
Minify JavaScript with UglifyJS3.,cause: The original UglifyJS error, if available.,Most UglifyJS error messages have the following properties:,github.com/terinjokes/gulp-uglify/
var gulp = require('gulp');var uglify = require('gulp-uglify');var pipeline = require('readable-stream').pipeline; gulp.task('compress', function () < return pipeline( gulp.src('lib/*.js'), uglify(), gulp.dest('dist') );>);
Answer by Cecilia Morgan
I am getting above error on gulp Build. so far i have tried all solutions of GulpUglifyError:Unable to minify JavaScript to no success. any ideas?,2 GulpUglifyError: unable to minify JavaScript (Angular 4),1 gulp js gave the error when i changed my js files..| throw er,2 Gulp.js can’t compile angular.js project due to excessive js errors?
[12:20:17] Finished 'images' after 12 s Error from uglify in compress task Error in plugin 'gulp-uglify' Message: D:\projects\Source\app\scripts\vendor.js: SyntaxError: Unexpected token: keyword (default) Details: fileName: D:\projects\Source\app\scripts\vendor.js lineNumber: 96908 [12:23:39] Finished 'fonts' after 3.55 min [12:23:49] Finished 'jshint' after 3.75 min