Node 0.12 ES6 multiparty string`identity error

  node.js, question


$ node -v


console.log(`string text line 1
 string text line 2`);


$node --harmony test.js

Error reporting:

console.log(`string text line 1
 SyntaxError: Unexpected token ILLEGAL
 at exports.runInThisContext (vm.js:73:16)
 at Module._compile (module.js:443:25)
 at Object.Module._extensions..js (module.js:478:10)
 at Module.load (module.js:355:32)
 at Function.Module._load (module.js:310:12)
 at Function.Module.runMain (module.js:501:10)
 at startup (node.js:129:16)
 at node.js:814:3

The v8 version in node.js is too low, it is 3: 00, so it does not support these ES6 features, including template string definition. You can switch to iojs. Currently, the latest version of iojs embedded v8 version is 4.4, which already supports quite a few ES6 features. The upcoming iojs embedded v8 4.5 already supports arrow>v*v)) such as Syntactic sugar.
At present, v8 is strengthening its support for ES6. Identifiers such as let and const have been supported for a long time. Although there are some problems with the syntax of class, it is also implemented in strict mode. Multi-line template strings and arrow functions are already in place. Some are still being implemented: for example, three-point parameter and three-point parameter, default value of parameter, etc.
Iojs generally follows v8 faster, so you can use it to meet your needs.
If you want to use node0.12 and use ES6 syntax, you can use babel as a precompilation tool. The deployment tool pm2 supports babel inline, or you can use it.