Unpolyfilled ES6 version of component fails to build with React-Create-App
See original GitHub issue- What version of RJEA are you using (react-json-editor-ajrm version)? *REQUIRED 2.5.5
- What operating system and processor architecture are you using? *REQUIRED Macbook Pro with Visual Studio Code
- What did you do? *REQUIRED Used the editor in my React page, which ran perfectly with “npm run dev”, but gives me error when “npm run build”.
- What did you expect to see? *REQUIRED Not an error
- What did you see instead? *REQUIRED An error:
" Creating an optimized production build… Failed to compile.
Failed to minify the code from this file:
./node_modules/react-json-editor-ajrm/es/index.js:12
Read more here: http://bit.ly/2tRViJ9
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! operation-react-app@0.1.0 build: react-scripts build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the operation-react-app@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
"
What did I do wrong?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Jest fails to run when node modules have es6 syntax ...
I have a create-react-app project and trying to unit test office-ui-fabric-react component using Jest and Enzyme . The latest version of ...
Read more >Create React App without Create React App
This article talks about the process of creating react app without using any libraries or frameworks such as “create-react-app” , “NextJS” etc.
Read more >How To Set Up a React Project with Create React App
You'll make your first changes to React code, update styles, and run a build to create a fully minified version of your application....
Read more >Building modular javascript applications in ES6 with React, ...
Our main target is to have a React application that is written in ES6 and uses our custom React components. The tricky part...
Read more >React Without ES6
Component { render() { return <h1>Hello, {this.props.name}</h1>; } }. If you don't use ES6 yet, you may use the create-react-class module instead:.
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
I tried to import react-json-editor-ajrm/index as you said, seems to compile. Thank you very much!!
If you look at the
package.json
of thereact-json-editor-ajrm
in yournode_modules
folder, you will see that it has an entry calledmodule
pointing to/es/index.js
.The
module
field is used to link to an ES6 version of the code. This is to be used by tools like webpack which can actually work with non commonjs modules. Tools that do not support it(likecreate-react-app
) should ignore it. But since nothing is perfect it looks likereact-scripts
1 has a bug that causes them to use this field regardless.The fix would either be:
react-scripts
2 (just released!)react-json-editor-ajrm/index
explictlyI understand that this is an inconvenience, but I don’t think we should change a correct setting in the
package.json
to work with a tools that interprets it incorrectly.