You can do it as follows:
console.log("**Socket.IO Version: " + require('socket.io/package').version);
The idea is to download the package.json file, which contains information about the Node package.
This is possible because Node require can also load JSON modules.
From docs :
If the exact file name is not found, then Node will try to load the required file name with the extension .js , .json , and then .node .
.js files are interpreted as JavaScript text files, and .json files .json parsed as JSON text files [...]
source share