Question

I've installed coffeescript and shellJS, using NPM. I have a test script, shtest.coffee:

#!/usr/local/bin/coffee
require 'shelljs/global'
echo 'hello'
exit 1

Running the script with coffee works fine:

$ coffee shtest.coffee
hello

Or with shjs:

$ shjs shtest.coffee
hello

But not directly:

$ chmod u+x shtest.coffee
$ ./shtest.coffee
./shtest.coffee: line 2: require: command not found
hello

Changing the shebang to point to /usr/local/bin/js doesn't help.

It looks like the script is being run as a bash script. What am I doing wrong? OS X Snow Leopard.

Was it helpful?

Solution

Try using

#!/usr/bin/env coffee

as your shebang line. That works for me at least, though I'm not sure why exactly (apart from it having to do with the ENV somehow)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top