npm run build: fails in node_module on "class" or prototype defination
See original GitHub issueIs this a bug report?
Not sure
Can you also reproduce the problem with npm 4.x?
Yes
Which terms did you search for in User Guide?
deploy configure
Environment
node -v
: v8.2.1npm -v
: 5.3.0yarn --version
(if you use Yarn):npm ls react-scripts
(if you haven’t ejected): react-scripts@1.0.12
Then, specify:
- Operating system: ubuntu 16.04
- Browser and version (if relevant):
Steps to Reproduce
(Write your steps here:)
- npm i eosjs-ecc
- require(‘eosjs-ecc’)
- npm run build
Expected Behavior
success
Actual Behavior
npm run build
> react-scripts build
Creating an optimized production build...
Failed to compile.
Failed to minify the code from this file:
../ecc/src/key_public.js:25
Read more here: http://bit.ly/2tRViJ9
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! keygen@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the keygen@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/.npm/_logs/2017-09-01T17_29_14_675Z-debug.log
Line 25 is either “class” in or in my local testing the first nonoccurence of “PublicKey.prototype.xxx =”
Reproducible Demo
none yet
Prototype and classes are pretty standard I’m not sure why this would fail…
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
Errors when running npm run build - node.js - Stack Overflow
If the build is defined in your package.json file, make sure that you are executing the 'npm run build' in the correct folder...
Read more >ts-error - npm
TL/DR: An extendable error class that actually works with TypeScript and ES6 support compatible with all environments, even very old browsers. ...
Read more >Best Practices for Node.js Error-handling - Toptal
In this article, Toptal Full-stack Developer Jay Huang will introduce you to error-handling in Node.js and demonstrate how you can build a robust ......
Read more >Errors | Node.js v19.3.0 Documentation
All JavaScript and system errors raised by Node.js inherit from, or are instances of, the standard JavaScript <Error> class and are guaranteed to...
Read more >Strict mode - JavaScript - MDN Web Docs
Browsers not supporting strict mode will run strict mode code with ... be in strict mode delete Object.prototype; // Will not throw error...
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 Free
Top 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
@jcalfee ah, that’s where our misunderstanding is!
We do not compile any code from
node_modules
, so it stays as-is. Even if we were to convert to Uglify v3, uses of class would leak into code targeting IE 9 since it could be parsed then, but then bomb out the browser.We do not compile
node_modules
because it’s incredibly slow and tends to break packages.Your concern is about the build output code version. But this issue is about the version of the dependent modules going into the build… These should be two different things.
How about run the babel es2015 conversion before Uglify v2? This is the code I used in my module to make it comparable with create-react-app. If create-react-app did this then many other modules would be spared from having to generate and deploy the generated copy to npm (which is a challenge to keep in sync).I think this is reasonable since old browsers do not run code directly from npm, they always go though a build process.
The trick is to create the more compatible generated code as late as possible.
node_modules/babel-cli/bin/babel.js src --out-dir lib