Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I run coffeescript in Heroku?

I have a node.js app written in CoffeeScript.

I'm wondering what is needed in order to host the app on Heroku.

Thanks

like image 781
donald Avatar asked Jun 15 '11 10:06

donald


2 Answers

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 start 21: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        [email protected] ./node_modules/coffee-script         [email protected] ./node_modules/jade         ├── [email protected]        └── [email protected] 

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 :)

like image 60
floriankrueger Avatar answered Sep 24 '22 14:09

floriankrueger


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.

like image 24
MichaelBlume Avatar answered Sep 23 '22 14:09

MichaelBlume