Electric Coffee
Electric Coffee

Reputation: 12104

Can't use template strings in node.js

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?

Upvotes: 9

Views: 14573

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1074495

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.

Upvotes: 23

Related Questions