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

151
Views
NodeJS TypeError: Cannot read property 'on' of undefined

I am new to node...If you need something more, please comment.

MY CODE :

io.socket.on('connection', function(socket){
    console.log('유저 접속 됨')

    socket.on('send', function(data){
        console.log('전달된 메시지: ', data.msg)
    })

    socket.on('disconnect', function(){
    console.log('접속 종료')
    })
})

and this console output :

TypeError: Cannot read property 'on' of undefined
at Object.<anonymous> (D:\Project\NodeJS\node-chat\app.js:32:11)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js         
(internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain]     
(internal/modules/run_main.js:76:12) 
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!