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

Unexpected token: keyword (const) #352

Closed
themeix opened this issue Mar 8, 2019 · 7 comments
Closed

Unexpected token: keyword (const) #352

themeix opened this issue Mar 8, 2019 · 7 comments

Comments

@themeix
Copy link

themeix commented Mar 8, 2019

Getting the following error while using uglify

GulpUglifyError: unable to minify JavaScript     
Caused by: SyntaxError: Unexpected token: keyword (const)
@aheiland
Copy link

gulp uglify uses node 4 - const/let is a knowen error of node below 5.3.0 - issue could be resolved by update node dependencie

@legendarydrew
Copy link

Adding minify as a dependency (I have ^4.1.3) seemed to have fixed this problem.

@avinzheng
Copy link

[20:36:24] GulpUglifyError: unable to minify JavaScript
Caused by: SyntaxError: Unexpected token: keyword «const»

My node version:

$ node -v
v12.18.1

My Gulp version:

$ yarn list --pattern=gulp       
yarn list v1.22.4
......
├─ gulp@4.0.2
......

My gulp-uglify version:

$ yarn list --pattern=gulp-uglify
yarn list v1.22.4
└─ gulp-uglify@3.0.2

@svivian
Copy link

svivian commented Jan 18, 2021

For anyone finding this through Google, this project is dead. The replacement is gulp-terser which supports modern JS features. It's basically a drop-in replacement - install it, add const terser = require('gulp-terser'); to your gulpfile, then you can just replace uglify() with terser()

@terinjokes
Copy link
Owner

This project is not dead. It still supports UgliftyJS, and the many forks of UgliftyJS, some of which are mentioned above. It will continue to adapt to continue working with future releases of UgliftyJS and Node.js

@svivian
Copy link

svivian commented Jan 18, 2021

Oh, apologies. UglifyJS is dead though, it doesn't support any JS from the past 5 years. And the version that supposedly replaced it (uglify-es) explicitly states to use terser instead. So the OP won't solve their problem with this plugin.

But a huge thanks from me for making this plugin, it's served me well for many years :)

@terinjokes
Copy link
Owner

You can use this plugin with terser, as shown on the README. At least it worked the last time I tried.

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

6 participants