Socket.IO Release

I updated socket.io from 0.9.16 to 1.0.6 and used to output the version as follows:

var io = require('socket.io'); console.log("**Socket.IO Version: "+io.version); 

and would give me

 **Socket.IO Version: 0.9.16 

After upgrading to 1.0.6, I get:

 **Socket.IO Version: undefined 

any help? Thanks!

+3
source share
1 answer

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 [...]

+3
source

Source: https://habr.com/ru/post/892522/


All Articles