npm run build fails for EventEmitter
Created by: godmar
@gaearon asked that I file a separate issue.
How to reproduce: run create-react-app fail-event-emitter
, add a line
import EventEmitter from 'events';
to src/index.js
and then run npm run build
, which fails with:
> fail-event-emitter@0.1.0 build /home/gback/fail-event-emitter
> react-scripts build
Creating an optimized production build...
Failed to compile.
static/js/main.068c41be.js from UglifyJs
Unexpected character '`' [/usr/lib/nodejs/events.js:260,0]
react-scripts 0.7.0 is used and node.js 6.9.1 (or 7.0)
The purported cause is that CRA does not transpile "dependencies" into ES5 and then the UglifyJS plugin fails when it encounters ES6 code. The test case above was derived from a failure in react-bootstrap-tables, which includes a module that in turn references EventEmitter. Others have suggested to provide an alternate EventEmitter implementation in the application path, but it is not clear to me how react-bootstrap-table's dependencies can be made to use this alternate implementation.