Node.js在传播运算符上失败
我有一个失败的node.js应用程序:
let x = [1]
let y = {...x};
有错误:
SyntaxError: /Users/.../index.js: Unexpected token (44:13)
42 | console.log(req.file, req.body);
43 | let x = [1]
> 44 | let y = {...x};
我曾尝试通过谷歌搜索这种行为,但无法找到解决方案。 es6的其他功能,例如let
和const
不会引起错误。
[node -v
给出v10.8.0
实际上,问题出在nodemon
中。我不得不改变.babelrc
来自
{
"presets": ["es2015"]
}
到
{
"presets": [
"@babel/preset-env"
]
}