Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

343
Vistas
Javascript - Error: Parsing file * : Unexpected token

i am trying use with enabled3d.io + geckos.io but Error: Parsing file ../server.js : Unexpected token Why am I getting this error

this is my code

import geckos from '@geckos.io/server'
import { createServer } from 'http'
import { promises } from "fs";
const { readFile, writeFile } = promises;
// import http from 'http'

const io = geckos()

const indexHtml = await readFile('src/index.html', { encoding: 'utf-8' })
const geckosJs = await readFile('src/js/geckos.io-client.2.1.2.min.js', {
    encoding: 'utf-8',
})

const requestListener = async (req, res) => {
    if (req.url === '/')
    return res.writeHead(200, { 'Content-Type': 'text/html' }).end(indexHtml)

    if (req.url === 'src/js/geckos.io-client.2.1.2.min.js')
    return res
        .writeHead(200, { 'Content-Type': 'application/javascript' })
        .end(geckosJs)

    return res.writeHead(404).end()
}

const server = createServer(requestListener)

io.addServer(server)

io.onConnection(channel => {
    channel.onDisconnect(() => {
    console.log('User ' + client.id + ' connected, there are ' + io.engine.clientsCount + ' clients connected')

    //Add a new client indexed by his id
    clients[client.id] = {
        position: [0, 0, 0],
        rotation: [0, 0, 0]
    }

    //Make sure to send the client it's ID
    client.emit('introduction', client.id, io.engine.clientsCount, Object.keys(clients))

    //Update everyone that the number of users has changed
    io.sockets.emit('newUserConnected', io.engine.clientsCount, client.id, Object.keys(clients))

    console.log(`${channel.id} got disconnected`)
    })

    //Handle the disconnection
    client.on('disconnect', ()=>{

    //Delete this client from the object
    delete clients[client.id]

    io.sockets.emit('userDisconnected', io.engine.clientsCount, client.id, Object.keys(clients))

    console.log('User ' + client.id + ' dissconeted, there are ' + io.engine.clientsCount + ' clients connected')

    })

    channel.on('chat message', data => {
    console.log(`got ${data} from "chat message"`)
    // emit the "chat message" data to all channels in the same room
    io.room(channel.roomId).emit('chat message', data)
    })
})

io.listen(3000) // default port is 9208

i'm making WebGL multiplay service As a novice developer, I'm looking at examples, but I have a question I don't know. and Error screenshot is here

enter image description here

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda