Can't use template strings in node.js

Electric Coffee picture Electric Coffee · Sep 29, 2015 · Viewed 12.8k times · Source

According to MDN, Template Strings should be working in Chrome, and by extension V8 on which Node.js is based on; but when I try the following I get a syntax error:

var name = 'coffee';
console.log(`Hello, ${name}!`);

running node file.js just results in a SyntaxError: Unexpected token ILLEGAL

Is there some kind of flag I need to enable to use this feature, or is it simply not implemented in node?

Answer

T.J. Crowder picture T.J. Crowder · Sep 29, 2015

Template strings were added in NodeJS v4.0.0. And I can confirm that they do work at least as far back as v4.1.1; I didn't bother to check v4.0.0, but I have no reason to doubt the linked announcement. No special runtime flag is required.