Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see socket.io version on node.js npm server

I want to confirm that should i upgrade to socket.io 0.7 , is my current app will not work on this server ? if i upgrade.

For this i want to see my current socket.io version , how can i see that?

and also on other side i want to go for stable version of node , currently we are having v0.5.0 pre , want to go for stable ersion for socket.io i read in a question of stackoverflow but not finding that question , lookoing for stable version to work with socket.io ,

will it will affect on my currentop running app if yes then should i upgrade on other server?

like image 775
XMen Avatar asked Jul 11 '11 19:07

XMen


3 Answers

For this i want to see my current socket.io version , how can i see that?

just open node.js in interactive mode by just typing node. Next you require('socket.io'). You will see a lot of information this way. If you just want to know your version number you could do require('socket.io').version.

alfred@alfred-laptop:~/node/contact$ node
> require('socket.io');
{ version: '0.7.6',
  protocol: 1,
  clientVersion: '0.7.3',
  listen: [Function],
  Manager: 
   { [Function: Manager]
     defaultTransports: 
      [ 'websocket',
        'htmlfile',
        'xhr-polling',
        'jsonp-polling' ],
     static: { cache: {}, paths: [Object], mime: [Object] } },
  Transport: [Function: Transport],
  Socket: [Function: Socket],
  Store: { [Function: Store] Client: [Function] },
  MemoryStore: { [Function: Memory] Client: [Function: Client] },
  RedisStore: { [Function: Redis] Client: [Function: Client] },
  parser: 
   { packets: 
      [ 'disconnect',
        'connect',
        'heartbeat',
        'message',
        'json',
        'event',
        'ack',
        'error',
        'noop' ],
     reasons: 
      [ 'transport not supported',
        'client not handshaken',
        'unauthorized' ],
     advice: [ 'reconnect' ],
     encodePacket: [Function],
     encodePayload: [Function],
     decodePacket: [Function],
     decodePayload: [Function] } }

require('socket.io').version '0.7.6'

and also on other side i want to go for stable version of node , currently we are having v0.5.0 pre , want to go for stable ersion for socket.io i read in a question of stackoverflow but not finding that question , lookoing for stable version to work with socket.io ,

will it will affect on my currentop running app if yes then should i upgrade on other server?

node.js are self containable executables and you can install multiple version of node without any problems. You should have a look at nvm or nave to help you manage multiple version of node.js. With this you can run different apps in different versions of node.js/npm without any pain.

For example right now node.js is running node v0.4.9 by default

alfred@alfred-laptop:~/node/contact$ nvm ls
v0.1.100  v0.1.16  v0.1.23  v0.1.30  v0.1.93  v0.2.0  v0.3.0  v0.3.7  v0.4.4
v0.1.101  v0.1.17  v0.1.24  v0.1.31  v0.1.94  v0.2.1  v0.3.1  v0.3.8  v0.4.5
v0.1.102  v0.1.18  v0.1.25  v0.1.32  v0.1.95  v0.2.2  v0.3.2  v0.4    v0.4.6
v0.1.103  v0.1.19  v0.1.26  v0.1.33  v0.1.96  v0.2.3  v0.3.3  v0.4.0  v0.4.7
v0.1.104  v0.1.20  v0.1.27  v0.1.90  v0.1.97  v0.2.4  v0.3.4  v0.4.1  v0.4.8
v0.1.14   v0.1.21  v0.1.28  v0.1.91  v0.1.98  v0.2.5  v0.3.5  v0.4.2  v0.4.8-rc
v0.1.15   v0.1.22  v0.1.29  v0.1.92  v0.1.99  v0.2.6  v0.3.6  v0.4.3  v0.4.9
stable:     v0.4.9
latest:     v0.4.9
current:    v0.4.9
default -> v0.4.9
# use 'nvm sync' to update from nodejs.org

alfred@alfred-laptop:~/node/contact$ node -v
v0.4.9

To change version I just type nvm use v0.4.8 which I have also installed.

alfred@alfred-laptop:~/node/contact$ nvm use v0.4.8
Now using node v0.4.8
alfred@alfred-laptop:~/node/contact$ node -v
v0.4.8
like image 50
Alfred Avatar answered Sep 23 '22 01:09

Alfred


The above answer is now not working for recent versions of Socket.io library. Please have a look on below link for the latest answer for getting the version of socket.io:

require('socket.io/package').version;

Socket.IO Version Output

like image 23
Shivam Avatar answered Sep 21 '22 01:09

Shivam


To find out what is the current version, simply execute npm list socket.io on your current project in the command line.

like image 44
Kent Aguilar Avatar answered Sep 21 '22 01:09

Kent Aguilar