question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:130 (54 by maintainers)

github_iconTop GitHub Comments

5reactions
godmarcommented, Nov 19, 2016

Ha!

I just did

npm install events --save

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.

3reactions
gaearoncommented, Dec 7, 2016

Fixed in #1194.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found