node.js / ES6 / class creation : SyntaxError: Unexpected reserved word

前端 未结 3 1832
-上瘾入骨i
-上瘾入骨i 2020-12-16 14:56

I try to create a class on my node.js / express app.

It works in basic js / prototype mode such as :

function MyClass() { 
    /* constructor code *         


        
3条回答
  •  孤街浪徒
    2020-12-16 15:16

    You need a newer version of nodejs. The class keyword is supported in 4.4.x, but I'm personally seeing it work in v4.2.6. (Not entirely sure what version of v8 released it, which is what would tell the node version.)

提交回复
热议问题