Node.js, Express.js - unexpected token {

后端 未结 2 1186
不知归路
不知归路 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.

    0 讨论(0)
  • 2021-01-28 12:18

    You tried to use destructuring assignment. AFAIK its support by nodejs v.6+ from a box and from 4.2.2 with flag --harmony_destructuring

    0 讨论(0)
提交回复
热议问题