npm run build fails for EventEmitter
See original GitHub issue@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.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:130 (54 by maintainers)
Top Results From Across the Web
npm run build - fails to compile despite development version ...
I have a react app created with create-react-app , and npm run build is failing to compile a production build. It throws the...
Read more >Getting npm build error prestart: `npm run build`
Hi,. I'm getting below error for npm start command, i have tried npm clear cache, npm install etc... but didn't resolved. Can you...
Read more >eventemitter3 - npm
EventEmitter3 is a high performance EventEmitter. It has been micro-optimized for various of code paths making this, one of, if not the fastest ......
Read more >Angular CLI ng build fails - Visual Studio Feedback
I have been trying to get a dotnet core 2.0, Angular CLI 1.5.0 & Angular 5.0.0 application to compile and I just cant....
Read more >npm run build 报错- CNode技术社区
... 1 verbose cli 'run', 1 verbose cli 'build' ] 2 info using npm@3.10.10 3 ... trip_h5@1.0.0~build: Failed to exec build script 14...
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
No results found
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
Ha!
I just did
in my directory and that worked! Am I dumb for not trying this right away?
And why does it work? I thought the way npm works is such that a package like recharts gets its own, or the default version of ‘events’ that the developer relied upon when building it… why can I override it in this way?
Very reminiscent of 2000’s Java CLASSPATH hell.
Fixed in #1194.