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?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: