Reputation: 35
I have nodejs on windows x64
on require('socket.io').listen(8080); or just require('socket.io'); i get this error:
C:\node>node applications/app.js
C:\node\node_modules\engine.io-client\lib\transports\polling.js:23
var xhr = new XMLHttpRequest({ xdomain: false });
^
TypeError: object is not a function
at C:\node\node_modules\engine.io-client\lib\transports\polling.js:23:13
at Object.<anonymous> (C:\node\node_modules\engine.io-client\lib\transports\
polling.js:25:3)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\node\node_modules\engine.io-client\lib\transports\
polling-xhr.js:6:15)
at Module._compile (module.js:460:26)
Upvotes: 0
Views: 1098
Reputation: 707976
It appears that you are somehow including the wrong socket.io
library. XMLHttpRequest
is a browser object and is only available in the browser. If you're using socket.io in node.js, you presumably want the server-side version of the library which would not be attempting to use XMLHttpRequest
.
And, when you look into the paths names, it appears you're somehow drawing in engine.io-client
which is not what you want.
This is the server-side module you want: https://www.npmjs.com/package/socket.io
If, by any chance you have the right module, but you are doing a require()
on the client module that is for the browser, then that could also cause the problem you are seeing as that would be a mistake and should be removed.
Upvotes: 1