Ask coding questions

← Back to all posts
Cannot GET Socket.io.js
MaxwellGeringer (0)

I am trying to use socket.io in my repl, but on the client side it tells me Cannot GET /socket.io/socket.io.js. The only solution I could find is to switch from using app.listen to http.listen but I have already done that but the same result occurs.

Answered by ruiwenge2 (551) [earned 5 cycles]
View Answer
Comments
hotnewtop
ruiwenge2 (551)

do this:

const express = require('express');
const app = express();
const http = require('http');
const server = http.createServer(app);
const { Server } = require("socket.io");
const io = new Server(server);
MaxwellGeringer (0)

@ruiwenge2 Hmm, I tried that but it tells me that http.listen is not a function. I switched it to app.listen but it still gives me the Cannot GET error.

ruiwenge2 (551)

@MaxwellGeringer you can take a look at my chat website: https://replit.com/@ruiwenge2/Chat

it uses socket.io. maybe it will help