Build React with Webpack Exception unexpected token

ERROR in ./app/main.js
Module build failed: SyntaxError: C:/Users/Yang/WebstormProjects/TestReact2/app/main.js: Unexpected token (6:13)

var React = require('react');
var AppComponent = require('./components/productBox.js');
React.render(<div><AppComponent/></div>, document.getElementById('content'))


This is because that babel can not tansform the react  jsx to js   

The revolution is :

1. ceate a file named .babelrc in project root

2. install npm install babel-plugin-transform-react-jsx

3. add code in .babelrc

{
  "plugins":["transform-react-jsx"]
}

相关推荐