Can I run coffeescript in Heroku?

I have a node.js application written in CoffeeScript.

I am wondering what is needed to host the application on Heroku.

thank

+50
coffeescript heroku
Jun 15 '11 at 10:23
source share
8 answers

Due to updates from Heroku, it now allows you to install the npm coffee-script source. The answer below was a workaround before Heroku fully supported node.js For a better solution, currently see a Higher Response Rating explaining how easy it is to use coffee-script from npm on Heroku.




Honestly, the best way would be to compile it before using it with coffee -c filename , as Peter suggested, but I'm wondering if there could be some kind of β€œpreload” preload.js that would call scripts using coffeescript like a node_module then compile () the script to be used. That way you can use them natively in node on heroku without having to deal with additional files in your repo.

 npm install coffee-script 

Then in the inital app write it in javascript and call the *.coffee files using the coffee compilation function:

 var coffee = require('coffee-script'); coffee.compile('./server.coffee'); // could be coffee.run(file) instead, not sure 

and in yourapp.coffee try

 console.log 'It worked!' 

I'm not sure if this will work, or even if this is even the correct syntax for this function. https://github.com/jashkenas/coffee-script/blob/master/lib/coffee-script.js#L24

If you are asking how to do this in ruby, here is this:

Walkthrough on using coffeescript on rails on Heroku: http://drnicwilliams.com/2010/03/15/using-coffeescript-in-rails-and-even-on-heroku/

Suggested to use bistro_car ( https://github.com/jnicklas/bistro_car )

 gem install bistro_car mkdir -p app/scripts 

and adding it to Rails conf/environment.rb

 config.gem 'bistro_car' 

If I find something else or another way to run *.coffee javascript applications, I will update this answer, but hopefully this will give you some idea on how to make it work.

Here are some more examples, but they all seem to use ruby ​​vs node.js:

http://forrst.com/posts/Doing_CoffeeScript_on_Heroku_a_Ruby_gem-OBk http://www.tangiblecolors.com/first-steps-with-coffeescript-and-how-to-use

Hope this helps a bit.

+1
Jun 15 2018-11-11T00:
source share

Michael Blum is right, and you do not need additional code to run CoffeeScript node applications on the hero. Here is how I did it:

Add coffee-script in the current version to your dependencies in package.json . It might look something like this:

 { "name": "My-CoffeeScript-App-on-Heroku", "version": "0.0.1", "dependencies": { "coffee-script": "1.1.2" } } 

Then change the entry for your node application in Procfile to use coffee instead of node. For an application with only one web entry, this might look like this:

 web: coffee app.coffee 

To check if this will work on Heroku, you can try it on the local host using the wizard's foreman:

 $ gem install foreman $ foreman start 21:13:36 web.1 | started with pid 4711 

Then try clicking on the hero and you will see something like this in the installation of dependencies:

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

I'm not sure there are problems with this procedure, but the method described above seems unnecessary to me since you messed up your code for the runtime environment.

Hope this helps someone :)

+118
Sep 13 '11 at 19:21
source share

I managed to do just fine by simply including coffeescript in my dependencies and then typing "coffee index.coffee" in my Procfile

When the server boots, the startup costs are loaded, but besides that, you should be fine.

+9
Aug 09 2018-11-11T00:
source share

I earned money by including a coffee script in my package.json package and adding node_modules / coffee- script / bin to my Heroku PATH folder

+2
Sep 09 2018-11-11T00:
source share

I googled around, but it seems incomprehensible. Here's a guide hero who doesn't mention the coffee pot. http://devcenter.heroku.com/articles/node-js

I think you can just run coffee -c . in your git repository of your application, before committing and clicking on the hero (the script is part of your script deployment)), and then simply use the .js code compiled by this process.

0
Jun 15 2018-11-11T00:
source share
  • Add coffee-script to your package.json
  • Change Profile to web: coffee app.coffee

See florian.k answer

0
Apr 08 '14 at 16:15
source share

For quite some time, Chris Fung has been a custom buildpack . I have been using it for several years, until recently, when it stopped working with the new Cedar-14 Stack on Heroku. So, I modified Chris's buildpack, and now you can use this new custom buildpack to run coffeescript applications on Heroku.

0
Sep 30 '15 at 15:17
source share

There is a great walkthrough of deploying a node.js application on Heroku here:
http://blog.superpat.com/2011/06/14/node-js-chat-demo-on-heroku/

-6
Jun 15 '11 at 12:22
source share



All Articles