Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR in bundle.js from UglifyJs SyntaxError: Unexpected token: name (x)

I have my app made with Reactjs.

I'm gettint this error when I try to run npm run-script build:

ERROR in bundle.js from UglifyJs
SyntaxError: Unexpected token: name (x)  [./react/stores/UserStore.js:52,20]

ERROR in bundle.js from UglifyJs
SyntaxError: Unexpected token: name (x)  [./react/stores/UserStore.js:52,20]

The error is thrown twice. And the line of the file that is poiting is commented! And now I try without those lines and I'm still getting the same error. But this is the first time that I have this error, don't know why, and i haven't touched that file in weeks...

Any idea?

like image 604
pmiranda Avatar asked Sep 13 '25 13:09

pmiranda


1 Answers

Well, in my case was that I didn't have babel-preset-es2015 so:

  1. npm install --save-dev babel-preset-es2015
  2. Add es2015 to webpack-production.config.js, like this: ['es2015', 'es2016', 'react']

The Uglify will work with es6 code (es6 -[babel preset es2015]-> es5 -> webpack with uglify plugin -> done)

like image 89
pmiranda Avatar answered Sep 16 '25 16:09

pmiranda