cyrf cyrf - 1 year ago 976
Node.js Question

string templates are not supported by current javascript version

I am trying to use ES6 String Templates in a Node.js (v 5.7.0) app, but they are not working. Webstorm is correctly warning me that

String templates are not supported by current Javascript version

I am sure I have used string templates in a node app in the past. How can I get string templates to work? I am running the server with this command

npm start

When that is fixed, how can I help Webstorm know it is fixed and stop showing the warning?

I changed the app source to use template strings in this manner:


var app = express();
var server = app.listen(process.env.PORT || 8080, function () {
var host = server.address().address;
var port = server.address().port;
console.log(`App listening at http://${host}:${port}`);


the app prints:

App listening at http://:::8080

Answer Source

Have you try in the REPL? It works for me.

enter image description here

If the code doesn't throw an error it means that the template strings works. But if the result is not what you expected, just console.log your variables to see what's inside.

Edit: Concerning the WebStorm warning, it seems pretty easy to fix.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download