Node - The Very Beginning

I'm in the process of building a web service that will eventually serve a mobile app I plan on writing. I'm building the service on Heroku using Node.js.

I chose Heroku because I want to explore using a hosted development environment and I really don't want to spend time administering servers when I can be writing code. I chose Node because it seems to be popular and because I want to give Javascript a second chance.

Over 12 years ago I completely wrote off Javascript and promised myself that I would never write another line of it. I really hated the language (but I loved Perl and still do, go figure). A lot has changed in that time. Lately I've been doing a bunch of game scripting in Unity 3D using Javascript and it has been enjoyable. I have also been warming to a more functional style of coding and Javascript gives me a nice, practical, playground to explore that a bit further. In retrospect, what I hated most about Javascript wasn't the language but the amount of work required to deal with cross-browser compatibility issues. Node let's me play with Javascript without the confines of the browser.

I will be posting lessons learned, observations made, and possibly some tutorials as I work my way through the process of building this service and learning a new development stack. Hopefully these posts will be of some use to somebody.

First Lesson

I was in the process of installing the PostgreSQL module pg for use with Heroku. My main development machines are currently OS X. In the process of installing the module I got a bunch of errors related to node-gyp.js

gyp ERR! build error 
gyp ERR! stack Error: not found: make
gyp ERR! stack     at F (/usr/local/lib/node_modules/npm/node_modules/which/which.js:43:28)
gyp ERR! stack     at E (/usr/local/lib/node_modules/npm/node_modules/which/which.js:46:29)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/which.js:57:16
gyp ERR! stack     at Object.oncomplete (fs.js:297:15)
gyp ERR! System Darwin 12.2.1
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /someDirectory/SomeWhere/node_modules/pg
gyp ERR! node -v v0.8.19
gyp ERR! node-gyp -v v0.8.4
gyp ERR! not ok 

In the end it turns out I did not have the Apple command line developer tools installed. This might sound like a simple mistake, and it is, but since Xcode has moved to a single application bundle it's pretty easy to forget that the common developer tools aren't readily available to the wider system.

To resolve this issue launch Xcode, then select Preferences -> Downloads -> Components and install the Command Line Tools package.

I realize this might seem like an obvious solution but I'm guessing I'm not the last person that will run into this issue.