내가 노드 버전 6.10.2 내가 코드
Node.js를 - 구문 에러 : 노드 6.10.2
import * as events from "events"
class MyClass extends events.EventEmitter {
constructor(x, y){
this.x = x;
this.y = y;
}
compute(){
return this.x * this.y;
}
}
var vow = new MyClass(2,3);
vow.compute();
나는이 오류를 얻고이의 peice를 실행하려고를 실행하고 실행 예기치 않은 토큰을 수입하면서, 나는 그것을 어떻게 만들 수 있습니까?
SyntaxError: Unexpected token import
가능한 중복 노드 V6.0.0에서 작동하지 Nodejs를 사용하려는 경우 ES5의 버전으로 ES6 코드를 은밀한 할
babel
을 사용해야합니다 함께 --harmony \ _modules 옵션] (http://stackoverflow.com/questions/36901147/es2015-import-not-working-in-node-v6-0-0-with-with-harmony-modules-option) –