2016-11-21 11 views
-2

私はES6の新機能を使用しており、webstorm ideを使用してnode.jsにサンプルクラスコードを書きました。SyntaxError:node.jsのブロックスコープ宣言webstorm

'user strict'; 

class PersonClass { 
    constructor(name) { 
     this.name = name; 
    } 

    sayName() { 
     console.log(this.name); 
    } 
} 

let person = new PersonClass('My Name'); 
person.sayName(); 

私はそれが私がバベル-CLI、バベル・プリセット-es2015がインストールされているにもかかわらず、エラー

class PersonClass { 
^^^^^ 

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode 
    at exports.runInThisContext (vm.js:53:16) 
    at Module._compile (module.js:373:25) 
    at Object.Module._extensions..js (module.js:416:10) 
    at Module.load (module.js:343:32) 
    at Function.Module._load (module.js:300:12) 
    at Function.Module.runMain (module.js:441:10) 
    at startup (node.js:139:18) 
    at node.js:974:3 

を表示するコードを実行します。どうすれば修正できますか?あなたがタイプミスを持って

+1

"ユーザー厳しい" のuse strictを書いてみては?このユーザーはここではっきりとスペルでは厳しくはありません... ;-P – deceze

+0

@deceze私の悪いことは気づいていません。ありがとう:) –

+0

またノード6にアップグレードし、これは問題ではありません。 – loganfsmyth

答えて

0

、代わりにuser strict

+0

おっと、私の悪い、ありがとう@元 –

関連する問題