<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[When running server: &quot;TypeError: Cannot read property &#x27;types&#x27; of undefined&quot;]]></title><description><![CDATA[<p>Hi, I'm running into a persistent error when trying to run a colyseus server. It starts up fine, but when I try to connect to the server from the client, I get the following error:</p>
<pre><code>&gt; ts-node src/index.ts

[gltd-server] running environment:  local
~you are now globally limited~
[gltd-server] Listening on 2657
TypeError: Cannot read property 'types' of undefined
    at Function.Reflection.encode (/Users/brianableson/gltd/globally.ltd/server/node_modules/@colyseus/schema/src/Reflection.ts:96:47)
    at SchemaSerializer.handshake (/Users/brianableson/gltd/globally.ltd/server/node_modules/colyseus/lib/serializer/SchemaSerializer.js:57:70)
    at Club.&lt;anonymous&gt; (/Users/brianableson/gltd/globally.ltd/server/node_modules/colyseus/lib/Room.js:292:136)
    at Generator.next (&lt;anonymous&gt;)
    at fulfilled (/Users/brianableson/gltd/globally.ltd/server/node_modules/colyseus/lib/Room.js:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
</code></pre>
<p>I am closely following <a href="https://github.com/endel/colyseus-babylonjs-boilerplate" rel="nofollow">this example</a>.</p>
<p>Here is my current <code>package.json</code> file:</p>
<pre><code>{
  &quot;name&quot;: &quot;globally-ltd-game-server&quot;,
  &quot;version&quot;: &quot;0.0.1&quot;,
  &quot;description&quot;: &quot;&quot;,
  &quot;main&quot;: &quot;index.js&quot;,
  &quot;scripts&quot;: {
    &quot;start-local&quot;: &quot;NODE_ENV=local onchange 'src/**.ts' -i -d 1000 -- ts-node src/index.ts&quot;,
    &quot;start-ts&quot;: &quot;ts-node src/index.ts&quot;,
    &quot;start&quot;: &quot;ts-node src/index.ts&quot;,
    &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;
  },
  &quot;author&quot;: &quot;&quot;,
  &quot;license&quot;: &quot;ISC&quot;,
  &quot;devDependencies&quot;: {
    &quot;@types/cors&quot;: &quot;0.0.33&quot;,
    &quot;@types/express&quot;: &quot;^4.17.6&quot;,
    &quot;@types/node&quot;: &quot;^13.11.1&quot;,
    &quot;onchange&quot;: &quot;^3.3.0&quot;,
    &quot;ts-node&quot;: &quot;^7.0.1&quot;,
    &quot;typescript&quot;: &quot;^3.8.3&quot;
  },
  &quot;dependencies&quot;: {
    &quot;colyseus&quot;: &quot;^0.12.6&quot;,
    &quot;cors&quot;: &quot;^2.8.1&quot;,
    &quot;express&quot;: &quot;^4.14.0&quot;,
    &quot;onchange&quot;: &quot;^3.3.0&quot;
  }
}
</code></pre>
<p>I'm new to typescript, so i'm guessing this is a noobish problem but i'm having trouble googling for the error. Thanks so much for your help in advance!</p>
]]></description><link>http://discuss.colyseus.io/topic/350/when-running-server-typeerror-cannot-read-property-types-of-undefined</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 13:27:48 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/350.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 13 Apr 2020 00:15:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to When running server: &quot;TypeError: Cannot read property &#x27;types&#x27; of undefined&quot; on Invalid Date]]></title><description><![CDATA[<p>Hi, I'm running into a persistent error when trying to run a colyseus server. It starts up fine, but when I try to connect to the server from the client, I get the following error:</p>
<pre><code>&gt; ts-node src/index.ts

[gltd-server] running environment:  local
~you are now globally limited~
[gltd-server] Listening on 2657
TypeError: Cannot read property 'types' of undefined
    at Function.Reflection.encode (/Users/brianableson/gltd/globally.ltd/server/node_modules/@colyseus/schema/src/Reflection.ts:96:47)
    at SchemaSerializer.handshake (/Users/brianableson/gltd/globally.ltd/server/node_modules/colyseus/lib/serializer/SchemaSerializer.js:57:70)
    at Club.&lt;anonymous&gt; (/Users/brianableson/gltd/globally.ltd/server/node_modules/colyseus/lib/Room.js:292:136)
    at Generator.next (&lt;anonymous&gt;)
    at fulfilled (/Users/brianableson/gltd/globally.ltd/server/node_modules/colyseus/lib/Room.js:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
</code></pre>
<p>I am closely following <a href="https://github.com/endel/colyseus-babylonjs-boilerplate" rel="nofollow">this example</a>.</p>
<p>Here is my current <code>package.json</code> file:</p>
<pre><code>{
  &quot;name&quot;: &quot;globally-ltd-game-server&quot;,
  &quot;version&quot;: &quot;0.0.1&quot;,
  &quot;description&quot;: &quot;&quot;,
  &quot;main&quot;: &quot;index.js&quot;,
  &quot;scripts&quot;: {
    &quot;start-local&quot;: &quot;NODE_ENV=local onchange 'src/**.ts' -i -d 1000 -- ts-node src/index.ts&quot;,
    &quot;start-ts&quot;: &quot;ts-node src/index.ts&quot;,
    &quot;start&quot;: &quot;ts-node src/index.ts&quot;,
    &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;
  },
  &quot;author&quot;: &quot;&quot;,
  &quot;license&quot;: &quot;ISC&quot;,
  &quot;devDependencies&quot;: {
    &quot;@types/cors&quot;: &quot;0.0.33&quot;,
    &quot;@types/express&quot;: &quot;^4.17.6&quot;,
    &quot;@types/node&quot;: &quot;^13.11.1&quot;,
    &quot;onchange&quot;: &quot;^3.3.0&quot;,
    &quot;ts-node&quot;: &quot;^7.0.1&quot;,
    &quot;typescript&quot;: &quot;^3.8.3&quot;
  },
  &quot;dependencies&quot;: {
    &quot;colyseus&quot;: &quot;^0.12.6&quot;,
    &quot;cors&quot;: &quot;^2.8.1&quot;,
    &quot;express&quot;: &quot;^4.14.0&quot;,
    &quot;onchange&quot;: &quot;^3.3.0&quot;
  }
}
</code></pre>
<p>I'm new to typescript, so i'm guessing this is a noobish problem but i'm having trouble googling for the error. Thanks so much for your help in advance!</p>
]]></description><link>http://discuss.colyseus.io/post/1149</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1149</guid><dc:creator><![CDATA[globallyltd]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to When running server: &quot;TypeError: Cannot read property &#x27;types&#x27; of undefined&quot; on Invalid Date]]></title><description><![CDATA[<p>I am seeing this relevant post but am having trouble figuring out exactly what was changed:</p>
<p><a href="https://discuss.colyseus.io/topic/298/types-of-undefined-in-reflection-js-error-in-unity/1" rel="nofollow">https://discuss.colyseus.io/topic/298/types-of-undefined-in-reflection-js-error-in-unity/1</a></p>
]]></description><link>http://discuss.colyseus.io/post/1150</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1150</guid><dc:creator><![CDATA[globallyltd]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to When running server: &quot;TypeError: Cannot read property &#x27;types&#x27; of undefined&quot; on Tue, 14 Apr 2020 11:50:42 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/655">@globallyltd</a> I have this error when I use and empty State. Then I try create a property in that state object and it works.</p>
]]></description><link>http://discuss.colyseus.io/post/1156</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1156</guid><dc:creator><![CDATA[boygiandi]]></dc:creator><pubDate>Tue, 14 Apr 2020 11:50:42 GMT</pubDate></item><item><title><![CDATA[Reply to When running server: &quot;TypeError: Cannot read property &#x27;types&#x27; of undefined&quot; on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/642">@boygiandi</a> Could you paste some code please, I'm having the same trouble but I can't fix it with your method :/</p>
]]></description><link>http://discuss.colyseus.io/post/1166</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1166</guid><dc:creator><![CDATA[Estournet]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to When running server: &quot;TypeError: Cannot read property &#x27;types&#x27; of undefined&quot; on Invalid Date]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/660">@Estournet</a></p>
<p>Apparently you need to have <strong>some</strong> field inside your state:</p>
<pre><code>import { Schema, type } from &quot;@colyseus/schema&quot;;

class YourState extends Schema {
  @type(&quot;string&quot;) xxxx;
}
</code></pre>
<p>I'll check what can I do on the next version to prevent this error from happening. Let me know if that fixes for you.</p>
<p>Cheers!</p>
]]></description><link>http://discuss.colyseus.io/post/1167</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1167</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to When running server: &quot;TypeError: Cannot read property &#x27;types&#x27; of undefined&quot; on Invalid Date]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a></p>
<p>Okay I figured out how to do. I had this trouble and I am using plain JS, which adds more trouble :p (and I hadn't read the documentation about State, I have to admit)<br />
So, if anyone has the same trouble, here is a solution for plain Javascript :</p>
<pre><code>import { Room } from &quot;colyseus&quot;;
// Imports need to be done with require for Schema
const schema = require('@colyseus/schema');
const { defineTypes, Schema } = schema;

export class TestState extends Schema {
  foo = &quot;bar&quot;;
  anything = &quot;you want&quot;
}

export class TestRoom extends Room {
  onCreate(options) {
    this.setState(new TestState());
  }
}

// This is the important part
defineTypes(TestState, {
  whatever: &quot;string&quot;
});
</code></pre>
<p>Thanks for the help !</p>
]]></description><link>http://discuss.colyseus.io/post/1168</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1168</guid><dc:creator><![CDATA[Estournet]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>