Node.js Socket.IO fix for 'sys' and 'util'

Node.js and Socket.IO have a compatibility error (as of 2010-10-22).

Node.js 0.3-pre has changed the word 'sys' to 'util' in many places.

Node.js 0.2:

  var sys = require('sys');

Node.js 0.3:

  var util = require('util');

Socket.IO-node hasn't caught up yet, which causes errors like this:

  The 'sys' module is now called 'util'.

This page is to document the error and show how to fix it.

How To Replicate

Get Node.js

  git clone git://github.com/ry/node.git
  cd node
  ./configure
  sudo make
  sudo make install

Get Socket.IO

  git clone git://github.com/LearnBoost/Socket.IO-node.git --recursive
  cd Socket.IO-node
  sudo make

The error message from make is:

  ./support/expresso/bin/expresso -I lib tests/*.js 
  The 'sys' module is now called 'util'. 
  It should have a similar interface.

Solution: change from 'sys' to 'util'

To fix Socket.IO-node, we must change 'sys' to 'util' in many files.

We want to change the files this way:

  1. Find all files
  2. Exclude the .git directory
  3. Exclude C programming files, which end in .c, .cpp, .h, .hcpp
  4. Select the files that have 'sys' including the quotation marks.
  5. Change every 'sys' to 'util'

To find the relevant files and change them:

  cd Socket.IO-node
  find . -name '.git' -prune -o -regex '.*\.\(c\|cpp\|h\|hccp\)$' -prune -o -print \
  | xargs grep "'sys'" -l \
  | xargs sed -i "s/\bsys\b/util/g"

Links



What's Next?

blog comments powered by Disqus