【问题标题】:Brunch build tool error while building react js构建反应js时早午餐构建工具错误
【发布时间】:2018-08-03 07:11:27
【问题描述】:

我在使用 brunch build 构建 React 组件时出错。 这个错误是关于什么的?

 error: Compiling of js/assets/jss/material-dashboard-pro-react/views/userProfileStyles.jsx failed. L5:4 js/assets/jss/material-dashboard-pro-react/views/userProfileStyles.jsx: Unexpected token 
     3 |   cardTitle,
     4 |   cardIconTitle: {
   > 5 |     ...cardTitle,
       |     ^
     6 |     marginTop: "15px",
     7 |     marginBottom: "0px",
     8 |     "& small": {

也出现了这个错误

14:44:44 - error: Compiling of js/components/Accordion/Accordion.jsx failed. L22:15 Unexpected token 
     20 |     };
     21 |   }
   > 22 |   handleChange = panel => (event, expanded) => {
        |                ^
     23 |     this.setState({
     24 |       active: expanded ? panel : -1
     25 |     });

【问题讨论】:

  • 这称为扩展语法,您很可能需要将babel-brunchstage 3 预设一起使用才能使用它。
  • @Tholle 感谢您的回答。我使用 npm install 安装和配置。像这样plugins: { babel: { presets: ["es2015", "react", "env", "stage-3"], // Do not use ES6 compiler in vendor code ignore: [/vendor/] } }, 但我遇到了错误
  • 不客气!很好,传播语法现在似乎正在工作。您现在收到类属性错误,即stage 2 proposal。试试"stage-2" 而不是"stage-3"

标签: javascript reactjs brunch


【解决方案1】:

spread syntaxclass properties 出现错误。

您可以安装 babel-brunch 和包含扩展语法和类属性的预设,例如 stage-2 preset

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-08
    • 2013-08-14
    • 2014-03-04
    • 1970-01-01
    • 2015-07-16
    • 1970-01-01
    • 2014-05-14
    • 2017-09-27
    相关资源
    最近更新 更多