Socket.IO error 'listen()' method expects an 'http.Server' instance after moving to Express 3.0

前端 未结 2 705
被撕碎了的回忆
被撕碎了的回忆 2021-02-12 18:53

I began learning Node.js today and I\'m a little stuck.

Following this example, I get the following error when I try executing the js file:

Warning: expr         


        
2条回答
  •  梦毁少年i
    2021-02-12 19:28

    Simplified to three lines of code that would be:

    var server = require('http').createServer(require('express')()),
    io = require('socket.io').listen(server);
    server.listen(8080);
    

提交回复
热议问题