unexpected token = for class properties in node 8.4 unexpected token = for class properties in node 8.4 node.js node.js

unexpected token = for class properties in node 8.4


Update
Support for instance class fields starts with node >= 12.


Literal class properties are not supported by any version of node, according to this table. You'll still have to set any instance properties inside your class constructor:

class TodoStore {    constructor() {        this.todos = [];    }    // ...}

If you wish to define a static property, you'd assign that directly to the TodoStore reference, after the class has been declared:

TodoStore.todos = [];


Instance class fields will be supported as of Node v12, so one solution is to use a version >= 12 once it is released.

https://node.green/#ESNEXT-candidate--stage-3--instance-class-fields

For now if you're interested the nightly builds are at: https://nodejs.org/download/nightly/