UglifyJs Syntax Error fails `npm run build` but not `npm start`
See original GitHub issueCan you reproduce the problem with latest npm?
Yes.
Description
One of my npm modules causes the production (npm run build
) builds to fail with an UglifyJs syntax error. However, I am able to run the app with npm start
without any errors or problems.
Expected behavior
Should be able to build production build if development build is working.
Actual behavior
When running npm run build
:
Creating an optimized production build...
Failed to compile.
static/js/main.455932b3.js from UglifyJs
SyntaxError: Unexpected token: operator (>) [./~/evolutionary/select1.js:5,0]
Environment
Run these commands in the project folder and fill in their results:
npm ls react-scripts
(if you haven’t ejected): react-scripts@0.7.0node -v
: v6.9.0npm -v
: v3.10.9
Then, specify:
- Operating system: Mac OS X Sierra
- Browser and version: N/A
Reproducible Demo
- Generate a new project with create-react-app
- Run
npm install evolutionary
- Put
import 'evolutionary'
at the top ofindex.js
- Run
npm start
. Confirm that app loads in browser w/ no errors. - Run
npm run build
. Error appears
I’ve never used webpack, but from my experience with browserify I would assume that ES6 syntax in dependencies would be handled just as fine as my app code.
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (2 by maintainers)
Top Results From Across the Web
npm run build uglifyjs: SyntaxError: Unexpected token: operator
The reason this is happening is because the ES6 code in your node_modules folder is not handled by create-react-app - it assumes they...
Read more >terser - npm
Start using terser in your project by running `npm i terser`. ... uglify-es is no longer maintained and uglify-js does not support ES6+....
Read more >How to Bundle JavaScript With Rollup — Step-by-Step Tutorial
Step 1: Install Rollup and create a configuration file. To get started, install Rollup with the following command: npm install --save-dev rollup. Next ......
Read more >Build failed SyntaxError: Unexpected token: name (length)
json below. I have no problem running npm run start but failed to compile npm run build with the following error: SyntaxError: Unexpected...
Read more >The best webpack configurations for React applications
Create React App (CRA) ships with webpack already under the hood, ... Run: $ npm run dev. Our app breaks, but it's not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
is there no solution to this???
It would be neat if create-react-app would support ES6 deps. there are a lot of dependencies I’m relying on (especially around cryptocurrencies/ethereum libs, that are primarly written for Node, and Node does support ES6 now!) that currently publish ES6 code (basically just code with
let
and arrow functions, nothing fancy) and i’m stuck by not being able to build my project.