I've been trying to load Socket.io into my application using RequireJS but it just keeps giving errors.

Versions used:

* **NodeJS:** 0.10.17
* **Socket.io:** 0.9.16
* **Socket.io-client:** 0.9.16
* **RequireJS:** 2.1.8

Solutions tried:
----------------

* From: <https://gist.github.com/guerrerocarlos/3651490>

**index.html**

```
require.config({
    shim: {
        'socketio': {
            exports: 'io'
        },
    },
    wrap: false,
    paths: {
        socket: '/socket.io/socket.io',
        jquery: "jquery-2.0.3.min",
        // Other dependencies
    }
});
require(["open_rpg"],function(OpenRPG){
    // App code here
});

```

**file.js**

```
define(["socket"],
    function(io){
        // Socket started here

```

Before using RequireJS socket was working. The Socket JS file is correctly loaded.

**Output:**

```
Uncaught TypeError: Cannot call method 'push' of undefined

```

---

* From: <https://github.com/LearnBoost/socket.io-client/issues/497>

I tried loading Socket.io as a normal JS script, and using:

```
paths:
  "socket.io": 'empty:'

```

But that returns:

```
Uncaught Error: Mismatched anonymous define() module: function () { return io; }

```

---

**Update:**
Since NodeJS keeps a modules cache I have added a modified copy of the Socket.io.js file, with line 107 changed as per solution 2 (See the link), and although this works, it's not a real solution. So I will keep this question open.

I have also tried adding the source of SocketIO as a normal JS file, and removing all references to it in RequireJS, but it still seems to be incompatible.