Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
HTML Script tag pointing to external source not working

I'm learning node js , so i decided to create a game and was setting up my project but ran into this issue.

My Script tag pointing to external source is not working, But when i copy paste the same javascript code into the html script tag it is working, Here are My code

index.html

<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Sanke Game</title>
  </head>
  <body>




  <script src="/socket.io/socket.io.js"></script>
  <script src="client.js"></script>
  </body>
</html>

client.js

const sockt = io("http://localhost:3000/");

sockt.on("serverToClient", function(event){
  alert(event);
})

app.js

const express = require("express");
const http = require("http");


const app = express();
const server = http.createServer(app);

const { Server } = require("socket.io");
const io = new Server(server);

app.get("/", function(req, res){
  res.sendFile(__dirname + "/index.html")
})

io.on('connection', function(socket){
  console.log("User is connected");
  socket.on("disconnect", function(){
    console.log("User Disconnected");
  })
  socket.emit("serverToClient", "Hello World");
})


server.listen(3000, function(){
  console.log("Listening to port 3000");
})

All files are in same level.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!