javascript - 如何解决 React 中的意外令牌 (<) 错误?
问题描述
与本教程相关:https ://www.youtube.com/watch?v=GieYIzvdt2U 我收到错误:
ERROR in ./leadmanager/frontend/scr/components/App.js 6:15
Module parse failed: Unexpected token (6:15)
You may need an appropriate loader to handle this file type.
| class App extends Component {
| render() {
> return <h1>React App</h1>
| }
| }
@ ./leadmanager/frontend/scr/index.js 1:0-35
当我跑步时 npm run dev
您可以在https://github.com/bewaresandman/django上找到我的代码
我很确定我的代码与教程中的代码完全一致,所以我很困惑。
编辑
.babelrc 和 webpack.config.js 文件位于错误的文件夹中。我修好了。没有错误:发生 ERROR in ./leadmanager/frontend/scr/components/App.js Module build failed (from ./node_modules/babel-loader/lib/index.js): SyntaxError: C:\Users\meissners\eclipse-workspace\django\leadmanager\frontend\scr\components\App.js: Unexpected token (6:15)
。
解决方案
你应该使用jsx
文件。
用and重命名你的index.js
and 。App.js
index.jsx
App.jsx
推荐阅读
- google-apps-script - Generate a list of Sheets that meet a condition in Google Scripts?
- go - 关闭响应流
- spring-boot - Maintaining multiple API representations in an API Gateway for a set of Spring Boot Microservices
- javascript - How to pull a random row from google sheets and use it in an HTML table
- amazon-web-services - 如何将外部位置作为 csv.gz 进行 CTAS
- mysql - How can I add a mysql Query to a node.js controller
- python - Add array of new columns to Pandas dataframe
- apache-spark - why isnull() and .isNull in Pyspark 1.6 producing different results?
- angular - Angular Components inside ngfor card list
- nattable - NatTable allow cell editing only when cell is selected