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

325
Views
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
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!