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

202
Views
Node.js socket.io problem emitting message server side

I'm trying to emit a message server side in Node.JS using Socket.io.

The socket.io connection is made in the app.js script.

The message is emitted in server.js script.

However I keep getting the error 'TypeError: io.emit is not a function'.

What could be the problem?

Thanks in advance!

app.js:


const app = require('./server'); // Fetch APIs
const socket = require("socket.io");

const port = 6000; // Processing Port

// Port session listener
const server = app.listen(port, () => {
    console.log(`App started on port ${port} ...!`)
})

// Socket setup
const io = socket(server);

// Export socket
module.exports={io};

server.js:


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

....
....
....

io.emit('processing-progress',`App has started ..!`);


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!