title: Socket.io can't find the server
body: <p>I am trying to use socket.io in my server. But it gives me this error: <code>GET http://localhost:4000/socket.io/socket.io.js net::ERR_ABORTED 404 (Not Found)</code>
  Here is my server code:</p>
  <pre><code>const app = express();
  const http = require('http');
  const server = http.createServer(app);
  var io = require('socket.io')(server);
  const taskRouter = require(&quot;./routers/tasks.js&quot;)
  
  app.use( &quot;/&quot; , taskRouter)
  
  io.on('connection', function (socket) 
  {
    console.log(&quot;Connected!&quot;)
  })
  
  app.listen(PORT, () =&gt; {
      console.log(`Server is on port ${PORT}`);
    });
  </code></pre>
  <p>Here is my pug code:</p>
  <pre><code>extends ../header2.pug
  block unique-css
      include ../../public/css/mentor/chat.css
  block unique-content
      .main
          h1 Hello World!
      script(src=&quot;/socket.io/socket.io.js&quot;)
      script
          include ../../public/js/mentor/chat.js
      
  </code></pre>
  <p>Here is my client-side javascript code:</p>
  <pre><code>var socket = io()
  
  socket.on('connection', function (data) {
    console.log(&quot;helloworld&quot;);
  });
  </code></pre>
  <p>And the problem is when I try to use socket.io I get this errors in browser <code>GET http://localhost:4000/socket.io/socket.io.js net::ERR_ABORTED 404 (Not Found)</code>, <code>Uncaught ReferenceError: io is not defined</code>. The second error is pointing to the first line of frontend js code.</p>