15 March 2012

Oy vey, coffeescript and node.js on Windows

I'm building a new site today. Just a small one, so this seemed like a good place to get started with node.js. Well, I found this really excellent blog post about it: 


http://www.davidarno.org/2012/02/02/beginners-guide-to-using-coffeescript-on-windows-with-node.js/ 


Nifty. So I get started and install coffee via npm. Now, just because I despise CMD (sooo 1990) I do this in PowerShell. OK, so I do the npm: 
PS>npm install -g coffee-script
npm http GET https://registry.npmjs.org/coffee-script
npm http 304 https://registry.npmjs.org/coffee-script
C:\Users\Justin\AppData\Roaming\npm\cake -> C:\Users\Justin\AppData\Roaming\npm\node_modules\coffee-script\bin\cake
C:\Users\Justin\AppData\Roaming\npm\coffee -> C:\Users\Justin\AppData\Roaming\npm\node_modules\coffee-script\bin\coffee
coffee-script@1.2.0 C:\Users\Justin\AppData\Roaming\npm\node_modules\coffee-script


Then I type 'coffee':

PS>coffee 
The term 'coffee' is not recognized as the name of a cmdlet, function, script file, 
OK, that's a path problem. So I use this rather tortured bit of syntax:
[Environment]::SetEnvironmentVariable( "Path", $env:Path + ";C:\Users\xxxx\AppData\Roaming\npm\node_modules\coffee-script;", [System.EnvironmentVariableTarget]::Machine )
Then restart powershell. Now when I type 'coffee' into Powershell I get this:


Say what?? Oy vey. Kinda gave up here.

Then I try it in Linux (in the VM):
~/app/log> sudo apt-get install coffeescript
[sudo] password for user: 
Reading package lists... Done
Building dependency tree       
etc... 
ldconfig deferred processing now taking place
~/app/log> coffee
coffee> ~/app/log> 
~/app/log> 
~/app/log> 
~/app/log>  coffee -bpe "alert i for i in [0..10]"
var i;
for (i = 0; i <= 10; i++) {
  alert(i);
}

Aaand, we're done. Every time this sort of thing happens, it's another nail in the coffin for me developing in Windows.