Chetan Motamarri Chetan Motamarri - 5 months ago 46
Node.js Question

Babel not transpiling from JSX to JS, tried manually without using webpack/browserify/bower

I am trying basic example in React.JS and using Babel to transpile from jsx to js. I hope I installed all babel dependencies, shown in package.json below. Also added App.jsx and index.html pages.

As shown in line 8 of package.json, I am trying to execute babel with "npm run build" but it is throwing error as shown in this terminal screenshot.

Any help appreciated.

enter image description here

enter image description here

enter image description here enter image description here

Answer

This happens when you don't configure Babel (properly).

Add this to your package.json:

"babel" : {
  "presets": ["es2015", "react" ]
}

More information here.