Grails, CoffeeScript and Eclipse

I’m using the Grails CoffeeScript plugin, but when running my Grails application from Eclipse, with run-app, I got the following error:

Compiling CoffeeScript Files ...ERROR Launching CoffeeScript compiler: Cannot run program "coffee": error=2, No such file or directory

Now, in order to fix this you need to tell the CoffeeScript Grails plugin where to find the coffee command. You can do this in BuildConfig.groovy by adding this line:

grails.coffeescript.compiler.location="/opt/local/bin/coffee"

But, this is not enough, because now I get the following error:

Compiling CoffeeScript Files ...env: node: No such file or directory

The solution I found to this problem was editing /opt/local/bin/coffee, changing

#!/usr/bin/env node

to

#!/opt/local/bin/node

Now I’m able to do run-app from within Eclipse.

Keep in mind that I’m on a Mac having installed CoffeeScript with npm, and node and npm with MacPorts. You might have your CoffeeScript installation in a different location.