Oct 10, 2013

Starting with Heroku and node.js on Windows: tips , tricks and tutorial comments

It seems like Heroku is one of the few "cloud hostings" out there giving support to Windows. I'm trying to start programming something with node.js and websockets, so that's why I played with it today. However, working on Windows and the toolbelt is not so easy.

Here are some tips:

  • Once you have your Heroku account, you will find the basic tutorial for node.js here.
  • Before doing anything install the Heroko toolbelt AND the Node.js installer for Windows. Node.js can be found here. RESTART windows so the PATH variable is set correctly. Save yourself a headache!
  • Very important: Install both toolbelt and the node.js in a directory without spaces on it's path (avoid Program Files and similar). I installed them on c:\Heroku and c:\nodejs. This will save you trouble.
  • Follow the tutorial. You will have to learn a bit of GIT usage if you don't know about it. Don't worry, the tutorial explains the basics.
  • The toolbelt installs some basic GUI client for windows, so you can commit more easily. However the guy on the videos uses TortoiseGIT. I guess it's even more practical to use, take a look at it.
  • You don't need to install GIT, it's included in the toolbelt (at least at present).
  • You don't need to open the Node.js console to work with it.
  • Here is a great video explaining some hidden tricks about the tutorial and Heroku. Follow it if you need to. Stop it also if you need to, because it's quite fast.
  • Running "npm install" in your working directory is needed to copy the dependencies locally.
  • Remember to create the other files stated on the tutorial, you need them all.
  • Foreman is your friend: you can test your app locally without commiting or deploying it to Heroku. Use it!
  • Once started with foreman ("foreman start" command in your work dir) you can see your app by
    typing this in your web browser: 127.0.0.1:5000 or localhost:5000. If you don't need much fancy graphics you can open a terminal an type curl 127.0.0.1:5000 or curl localhost:5000 (curl is included in the toolbelt).
  • Common problems with Foreman
    • Bad file descriptor: it seems that there is a problem with latest versions of foreman you must run:
      • gem uninstall foreman 
      • gem install foreman -v 0.61
    • node command unknown: You forgot to install node.js maybe? 

Well I hope to save someone some trouble with this info. In case of doubt look at the video, although it doesn't show the use of foreman, it's quite good at everything else.

References: thanks to the guys on Stack Overflow for some of the info contained here, and also thanks to mescalito2 for his great video.