0
我在windows x64上有nodejsNodejs在require('socket.io')上抛出错误
on require('socket.io')listen(8080);或者只需要('socket.io');我得到这个错误:
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)
不,它是相同的版本。它包括服务器和客户端模块,但感谢您的回答,我只是评论// var client = require('socket.io-client');在socket.io中,它的工作原理! – Pavel 2015-02-12 09:11:52
@ПавелШаталов - 为什么你说错误发生在'require('socket.io');'?那不是真的吗?无论如何,我已经在答复中添加了一条以解决您发现的问题。 – jfriend00 2015-02-12 13:59:03
我的app.js只有containts require('socket.io');而socket.io库包含require('socket.io-client')。我不得不编辑socket.io来防止这个错误。但我仍然不明白,为什么简单的要求导致这个错误; – Pavel 2015-02-12 14:20:03