Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

318
Visualizações
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.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda