export ES6 class in Node 4.x Unexpected reserved word

后端 未结 2 733
抹茶落季
抹茶落季 2021-01-02 10:02

I have the following in a Node scripts:

\"use strict\";

class Whatever {
    constructor() {
        console.log(\"I\'m in the constructor!\");
    }
}

exp         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-02 11:02

    ES6 modules aren't stable in Node yet, but you can use --harmony_modules to enable them. This obviously is not recommended in a production environment.

    ES6 support in Node 4.x

提交回复
热议问题