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

170
Views
La etiqueta HTML Script que apunta a una fuente externa no funciona

Estoy aprendiendo node js, así que decidí crear un juego y estaba configurando mi proyecto, pero me encontré con este problema.

Mi etiqueta de secuencia de comandos que apunta a una fuente externa no funciona, pero cuando copio y pego el mismo código javascript en la etiqueta de secuencia de comandos html, funciona, aquí está mi código

índice.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>

cliente.js

 const sockt = io("http://localhost:3000/"); sockt.on("serverToClient", function(event){ alert(event); })

aplicación.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"); })

Todos los archivos están en el mismo nivel.

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!