相关疑难解决方法(0)

如何解决错误:“jsx”当前未启用

我是reactjs新手。我读过类似的错误帖子,语法错误:当前未启用对实验性语法“jsx”的支持 ,但无法解决我的问题

当我跑步时npm run dev

我有一个错误

ERROR in ./src/index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: -..../frontend/src/index.js: Support for the experimental syntax 'jsx' isn't currently enabled (40:7):

  38 |   render() {
  39 |     return (
> 40 |       <ul>
     |       ^
  41 |         {this.state.data.map(contact => {
  42 |           return (
  43 |             <li key={contact.id}>

Add @babel/preset-react (https://git.io/JfeDR) to the 'presets' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://git.io/vb4yA) to …
Run Code Online (Sandbox Code Playgroud)

javascript npm reactjs

7
推荐指数
1
解决办法
3万
查看次数

标签 统计

javascript ×1

npm ×1

reactjs ×1