javascript - Transpiling jsx using babel for react app -
i trying transpile jsx file using babel , giving error.
the content of file follows, (src/app.js
)
class channel extends react.component{ render() { return( <li> </li> ) } }
i used following commands transpile , watch file changes.
1) babel src/app.js --watch --out-file js/app.js 2) babel src/app.js --presets es2015 --watch --out-file js/app.js
in both cases recieved following error,
syntaxerror: src/app.js: unexpected token (4:12) 2 | render() { 3 | return( > 4 | <li> </li> | ^ 5 | ) 6 | } 7 | }
it shows error @ start of html tags embedded in javascript file (jsx). babel expected know html tags , treat , compile it, don't know why behave that.
note: installed babel using babel documentation official website.
you'll need react
preset well.
to install it:
npm babel-preset-react
to use it:
babel src/app.js --presets es2015,react --watch --out-file js/app.js
Comments
Post a Comment