Can I make a CoffeeScript file executable just like a Perl or shell script?
Something like adding
#!coffee
on top? (I tried that, and all I get is 'bad interpreter')
I'm on OS X if that makes a difference.
You can use:
#!/usr/bin/env coffee
console.log 'hello coffeescript!'
Just make sure you also make the file executable:
chmod +x myfile.coffee
Then you can run it with:
myfile.coffee
Have you tried the absolute path? "Bad interpreter" usually means there's a rogue newline at the end, e.g. you need to run dos2unix
on it.
You need an absolute path (on linux at least, OSX may be different)
or you can cheat by using env
#!/usr/bin/env coffee
# **Your script here**
It looks like you've already made sure you've made the script executable if you are getting that error
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With