Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

124
Vistas
how to fix 'require is not defined' error in socket.io?

In an express.Js project i have socket.io installed for my server and socket.io-client for my client and the projected is bundled using webpack5.

in my client i have this code;


const { io } = require("socket.io-client");

const socket = io();

socket.on("connect", () => {
      console.log(socket.id);
});

and when i run the command to build it compiles without problems but in the browser i get the error ;

Uncaught ReferenceError: require is not defined

how can i fix this ?

i couldn't find a good answer here ; Socket.IO - require is not defined

thanks in advance.

7 months 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 empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.