colyseus / colyseus.js

⚔ Colyseus Multiplayer SDK for JavaScript/TypeScript
https://docs.colyseus.io/getting-started/javascript-client/
MIT License
410 stars 107 forks source link

Does it work in Node? #79

Closed radiantone closed 4 years ago

radiantone commented 4 years ago

When I try to run a simple client in nodejs it produces error

var client = new Colyseus.Client('ws://localhost:8002'); ^ TypeError: Colyseus.Client is not a constructor at file:///xxxx/client.js:5:14 at ModuleJob.run (internal/modules/esm/module_job.js:140:23) at async Loader.import (internal/modules/esm/loader.js:162:24)

radiantone commented 4 years ago

The answer is to add this

Colyseus = require('colyseus.js');

instead of

import * as Colyseus from "colyseus.js"; // not necessary if included via Githubissues.

  • Githubissues is a development platform for aggregating issues.