Archive | July, 2011

Node.js Module not found

28 Jul

I am enjoying butchering Node.js these days.
I followed installation instructions to the letter and still stuff keeps not working.

The most common error is related to node.js not finding some module.

Get this node.js !


Once again, it's ugly but it works.. just insert your node path in there. I guess eventually everything will get fixed but in the meantime I just need things to work so I can experiment with these technologies.
If you know a better way to do it, please let us know.

Node.js experiments – getting Zappa to work

27 Jul

These days we are playing with serverside javascipt programming using node.js and coffeescript.  Zappa looks like a promising web development framework, strongly based on the ruby-based Sinatra.

We installed it with the standard

 npm install zappa --global 

but for some reason any time we tried to run it we got a big Cannot find module ‘coffee-script/lib/optparse’ error.

Anyway, we managed to do an ugly hack that got it to work.

1/ Find where npm installed your zappa module. In our case we found it via the error message: /opt/local/lib/node/.npm/zappa/0.1.5/package/bin/zappa

2/ Go there and open the package/lib/cli.js file

3/ Find the failing statement: OptionParser = require(‘coffee-script/lib/optparse’).OptionParser;

4/ Jam in the absolute path. In our case it was:

OptionParser =  require(‘/opt/local/lib/node/.npm/coffee-script/active/package/lib/optparse’).OptionParser;

5/ Ugly as hell, but now it works!

It looks like node had trouble resolving the path of the coffeescript sub-library and this is the only way we could make it work.

Do you have a more elegant solution?