Node.js, Express.js - unexpected token {

后端 未结 2 1185
不知归路
不知归路 2021-01-28 11:35

My app crashes every time it reaches this line:

const {name, price} = req.query;
        ^

can\'t seem to locate the exact answer..here is the

2条回答
  •  深忆病人
    2021-01-28 11:59

    According to node.green, the object destructuring with primitives syntax works after Node.JS v6.4.0, and throws the Unexpected Token { on Node.js versions below that.

    Also, the object rest/spread properties only works out of the box from Node v8.6.0. It works in v8.2.1 with the --harmony flag, and throws the Unexpected Token ... on Node.js versions below that.

提交回复
热议问题