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.

Unpolyfilled ES6 version of component fails to build with React-Create-App

See original GitHub issue
  1. What version of RJEA are you using (react-json-editor-ajrm version)? *REQUIRED 2.5.5
  2. What operating system and processor architecture are you using? *REQUIRED Macbook Pro with Visual Studio Code
  3. 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”.
  4. What did you expect to see? *REQUIRED Not an error
  5. 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? screen shot 2018-09-27 at 13 36 37

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
valenticanadellcommented, Oct 3, 2018

I tried to import react-json-editor-ajrm/index as you said, seems to compile. Thank you very much!!

0reactions
PatrickSachscommented, Oct 4, 2018

If you look at the package.json of the react-json-editor-ajrm in your node_modules folder, you will see that it has an entry called module 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(like create-react-app) should ignore it. But since nothing is perfect it looks like react-scripts 1 has a bug that causes them to use this field regardless.

The fix would either be:

  • Update to react-scripts 2 (just released!)
  • Import react-json-editor-ajrm/index explictly

I 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.

Read more comments on GitHub >

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

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