colyseus.js: server error: registeredHandler.klass is not a constructor

Hi there ! I finally succeed at running my server and my client with webpack and typescript ... but now i have a wierd error in chrome :

colyseus.js: server error: registeredHandler.klass is not a constructor

Does any one know what is it and where is it from...

I googled it and i found NOTHING it's scare me a lot ...

Hi @erochongit,

Make sure to use "target":"es2015" in the tsconfig.json on your server:

    "compilerOptions": {
        "target": "es2015",
    // ...

@endel i did this it's not correct ?

  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "noImplicitAny": false,
    "sourceMap": true,
    "outDir": "build"
  "exclude": [
  "include": [

EDIT : I have the same error when i add "target": "es2015", to my tsconfig.json.

same error here, any solution ?

If that doesn't solve the issue, it would be nice if you could provide an example of how to reproduce the issue. Cheers!

Sorry for the late reply!

I just finished a project where i'm able to run client but having .klass issue ...

please use develop branch

here it is :

If you are not able to run it properly tell me i'll help you

Hi @erochOnGit, I see. Thanks for sharing your project.

The issue you're having is because you're using both commonjs and es6 module systems at the same time. A common practice is to either always use require + module.exports, or import + export, never both.

You can fix the issue by using import { MyRoom } from "./defaultRoom.ts" here. Or by exporting the room using commonjs, by using module.exports = class MyRoom {...

@Diederik-Van-Remoortere is that your scenario as well?

Hi all,

I'm just starting out with your framework and I'm rather new to ES6 as well, so I'm probably a bit confused.

The things I'm confused about are:

  • should I use babel ? if yes, which version ? @erochOnGit in your nodeGame repo you are using @babel which seems to be a beta version of babel, is this intentionally ?
  • which babel preset should I use ?
  • should I use type script or javascript ? (i prefer the later...)
  • I 'd prefer to write my code using the ES6 syntax (i.e. using import i.s.o require()...), your examples are also written in it...

It might be a good idea to update your getting started section on the website as it is currently a bit weird to clone a git repo to start a new project instead of using npm install commands.... I'm just being frank here ;)

I stumbled upon your project by accident for a multiplayer demo game I'm currently co-working on with some colleagues, and it would be nice to continue using Colyseus for it...

Thanks for your responses, apologies for the late reply.

Best Regards,


You must use typescript, I tried with babel but it was wrong.
In my repo I forgot to remove babel from the package.json

@endel said in colyseus.js: server error: registeredHandler.klass is not a constructor:

Or by exporting the room usin

I'll try it the week end and come back to you later.
Thx for the help so far.