Socket.io扔了错误:fn.bind不是一个函数

时间:2017-10-19 15:16:53

标签: mongoose socket.io nodes

我在尝试从书中构建多房间聊天应用程序时遇到了同样的错误" Node.js in action" 为什么会发生,我该如何解决?请帮忙〜

<MY_PATH>\chatapp\node_modules\socket.io-adapter\index.js:210
  if (fn) process.nextTick(fn.bind(null, null, sids));
                              ^

TypeError: fn.bind is not a function
    at Adapter.clients (<MY_PATH>\chatapp\node_modules\socket.io-adapter\index.js:210:31)
    at Namespace.clients (<MY_PATH>\chatapp\node_modules\socket.io\lib\namespace.js:256:16)
    at updateUserList (<MY_PATH>\chatapp\socket\socket.js:49:41)
    at Socket.<anonymous> (<MY_PATH>\chatapp\socket\socket.js:22:7)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at <MY_PATH>\chatapp\node_modules\socket.io\lib\socket.js:514:12
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

1 个答案:

答案 0 :(得分:0)

This seems to be an error related to the version of socket.io you are using. Make sure that in your package.json file, you set it to not use the latest version of the required dependencies, but rather to only specifically use the versions mentioned in the book.

Please refer to the following link for further information

https://github.com/socketio/socket.io/issues/2428

Hope this helps !