What does require('socket.io')(http) mean in node js

Please what is the meaning of require(‘socket.io’)(http) in Node.js

Can you show us a code sample so we can understand how it’s used in context?

This site may well be what it’s referring to though - socket.io

It looks like it may be bringing in a library

It has two parts, requiring a module with CommonJS

require('socket.io')

And calling the function it returns, passing in an http variable.

(http)

Can be rewritten as

var socketio = require('socket.io');
socketio(http);
1 Like

Thanks markbrown4. This answered my question.

Thanks guys for the help.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.