当前位置:   article > 正文

webpack编译时报错Module build failed,SyntaxError: Unexpected token> <div>_module build failed: syntaxerror: unexpected token

module build failed: syntaxerror: unexpected token

webpack编译时报错

ERROR in ./src/components/App.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: Unexpected token (9:6)

   7 |   render() {
   8 |     return (
>  9 |       <div>
     |       ^
  10 |         <img src={Icon}/>
  11 |         <p>react demo</p>
  12 |       </div>

 @ ./src/index.js 3:11-38
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

解决办法

1.看看.babelrc名字有没有拼错
2.babel的preset有没有引入 react……(我就是忘记引入react了……)

{
    "presets": [
        "env", // 支持es6写法
        "react"
    ],
    "plugins": [
        "transform-runtime"
    ]
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/228953?site
推荐阅读
相关标签
  

闽ICP备14008679号