Can I run coffeescript in Heroku?
Michael Blume is right and you don't need any extra code to run CoffeeScript node apps on heroku. This is how I did it:
Add the coffee-script
in the current version to your dependencies in package.json
. This might look somewhat like this:
{ "name": "My-CoffeeScript-App-on-Heroku", "version": "0.0.1", "dependencies": { "coffee-script": "1.1.2" }}
Then modify the entry for your node app in the Procfile
to use coffee instead of node. For an app with only a single web entry this might look like this
web: coffee app.coffee
To test if this will work on Heroku, you can try it on localhost using the foreman gem:
$ gem install foreman$ foreman start21:13:36 web.1 | started with pid 4711
Then try a push to heroku and you will see something like this in the dependency installation:
-----> Installing dependencies with npm 1.0.8 coffee-script@1.1.2 ./node_modules/coffee-script jade@0.15.3 ./node_modules/jade ├── mkdirp@0.0.6 └── commander@0.1.0
Not sure if there are issues with that procedure but the method described above seems like overkill to me since you're messing up your code for runtime environment stuff.
Hope this helps somebody :)
I was able to get along fine by just including coffeescript in my dependencies and then putting 'coffee index.coffee' in my Procfile
There's a startup cost to compiling each time your server boots, but other than that you should be fine.
I got it working by including coffee-script in my package.json and adding node_modules/coffee-script/bin to my Heroku PATH