# Error with typescript + socket.io

**URL:** <https://phaser.discourse.group/t/error-with-typescript-socket-io/6541>\
**Category:** Phaser 3\
**Created:** [June 3, 2020, 3:25am UTC](https://phaser.discourse.group/t/error-with-typescript-socket-io/6541 "2020-06-03T03:25:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rayder1](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/rayder1/32/3505_2.png) [@rayder1](https://phaser.discourse.group/u/rayder1)\
**Post date:** [June 3, 2020, 3:25am UTC](https://phaser.discourse.group/t/error-with-typescript-socket-io/6541/1 "2020-06-03T03:25:07Z")

</div>

im getting this error on the console web browser:  
ReferenceError: module is not defined  
this is my code

```
import * as socketio from 'socket.io-client'

this.socket = socketio.connect('http://localhost:3000');
this.socket.on('connect', (socket) => {
    console.log('connected');
});

```

im getting this errors too  
rollup v1.29.0  
bundles ./src/game.ts → dist\game.js…  
(!) Unresolved dependencies  
socket.io-client (imported by src\scenes\menu.ts)  
(!) Missing global variable name  
Use output.globals to specify browser global variable names corresponding to external modules  
socket.io-client (guessing ‘socketio’)  
created dist\game.js in 5.4s

```
// We need to convert the Phaser 3 CJS modules into a format Rollup can use:
commonjs({
    include: [
         'node_modules/eventemitter3/**',
          'node_modules/phaser/**',
          'node_modules/socket.io-client/**'
    ],
    exclude: [ 
         'node_modules/phaser/src/polyfills/requestAnimationFrame.js'
   ],
   sourceMap: true,
    ignoreGlobal: true
 }),

```

the unresolved dependecies should be solved with?

```
'node_modules/socket.io-client/'

```

i dont know why dont let me import like this:

```
import io from 'socket.io-client'

```

im getting this error:  
Module ‘“socket.io-client”’ can only be default-imported using the ‘esModuleInterop’ flagts(1259)

index.d.ts(9, 5): This module is declared with using ‘export =’, and can only be used with a default import when using the ‘esModuleInterop’ flag.

How should i import the module?

Someone know wich is the problem? some hint? is the rollup the problem?  
thx

---

<div class="post-metadata">

**Author:** ![yannick](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/yannick/32/732_2.png) [@yannick](https://phaser.discourse.group/u/yannick)\
**Post date:** [June 3, 2020, 12:36pm UTC](https://phaser.discourse.group/t/error-with-typescript-socket-io/6541/2 "2020-06-03T12:36:33Z")

</div>

Have you tried using webpack?  
Try my template [Phaser 3 - Starter Templates with ES6+ (ESNext) or TypeScript](https://phaser.discourse.group/t/phaser-3-starter-templates-with-es6-esnext-or-typescript/954)

---

<div class="post-metadata">

**Author:** ![snowbillr](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/snowbillr/32/332_2.png) [@snowbillr](https://phaser.discourse.group/u/snowbillr)\
**Post date:** [June 3, 2020, 3:31pm UTC](https://phaser.discourse.group/t/error-with-typescript-socket-io/6541/3 "2020-06-03T15:31:03Z")

</div>

Not really a helpful answer, but this seems like it might get a better response on a Rollup support forum rather than the Phaser one /shrug
