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"] }
相关推荐
不知道该写啥QAQ 2020-08-02
不知道该写啥QAQ 2020-06-10
游走的豚鼠君 2020-11-10
81417707 2020-10-30
ctg 2020-10-14
小飞侠V 2020-09-25
PncLogon 2020-09-24
jipengx 2020-09-10
颤抖吧腿子 2020-09-04
wwzaqw 2020-09-04
maple00 2020-09-02
青蓝 2020-08-26
罗忠浩 2020-08-16
liduote 2020-08-13
pengruiyu 2020-08-01
wmd看海 2020-07-27
孝平 2020-07-18
Eduenth 2020-07-05