How to use ES Classes in server node code?

I’m a node noob so apologies if this is a silly question… I want to use classes, and I read that they’re only supported in strict mode. I tried doing this:

"use strict";
class a {

But it gives this error:

class a {
SyntaxError: Unexpected reserved word

Is it possible to make this work?

1 Like

Ok, I think this might be due to the node version. process.version returns v0.12.2 (which seems quite old, pre io.js according to this page). However in my packages.json I have this (which was in the template project):

"engines": {
	"node": "5.4.1"

Any ideas?

1 Like

Yeah to prove the idea we have been running on 0.12.2 as the sole node environment. I feel there is a strong case to be less old :smiley:

We will be looking to add more supported options and do a better job of making that user selectable.

Thanks for the feedback and sorry for the confusion!



There’s already an engines section in packages.json which is probably fine for selecting.

A newer version would really help though… I’m sort-of abandoning my TypeScript testing ;( Simple cases worked but it doesn’t seem to be compiling the modules/scripts properly when I tried adding more (I think a ts-node issue). ES classes would be much more tolerable than old-skool JS :grin:

1 Like

It would be great to at least keep up with the recommended LTS version at, currently 4.4.5. Looks like HyperDev is now 4.4.3 so maybe that’s close enough. Of course even better would be to actually use the version specified in packages.json!