如何解决webpack 2错误,模块构建失败:SyntaxError ,,?
问题描述:
我克隆此reactjs/webpack2回购:如何解决webpack 2错误,模块构建失败:SyntaxError ,,?
https://github.com/ModusCreateOrg/budgeting-sample-app
这是伟大的工作,但我玩弄和chaned的index.js文件的一些属性/传播:
let myprops = [1,2];
let copyprops = {...myprops};
当我跑故宫开始我得到一个生成错误:
Module build failed: SyntaxError: .../index.js:Unexpected token
它是指与传播OPERAT行或者,我该如何解决这个问题? 还看到:repo
答
如果你没有改变被包含在回购的预设,然后蔓延运营商不会因为你发现工作。
展开运算符实际上是stage2预置的一部分。您可以依次找到,这里https://github.com/babel/babel-loader/issues/170
因此,更多的信息为你的代码工作,你需要确保你已经同时装有babel-preset-stage-2
并在.babelrc
答
嗯,我会做`
class App extends Component {
render() {
let myprops = [1,2];
let [...a] = myprops;
return (
<div className="viewport">
</div>
);
}
}
只是快速解决方案。“参考here。谢谢
这不会解决用户遇到构建失败时遇到的问题。 https://babeljs.io/docs/plugins/transform-object-rest-spread/#example-spread-properties –