GulpUglifyError: unable to minify JavaScript Caused by: SyntaxError: Unexpected token: keyword const

Updated: 11th December 2021
Tags: javascript gulp

Issue

gulp-uglify doesn’t support ES6 (JavaScript ECMAScript 6), so you need other tool.

Fortunately, there is another package which do same thing and have same command.

Solution

  1. Type this to install gulp-terser
npm install gulp-terser --save-dev
  1. Change gulp-uglify to
const uglify = require("gulp-terser");