CoffeeScript in Sublime Text on Windows

I work on both Ubuntu and Windows, and just recently switched to the Sublime Text 2 editor, which is a nice cross between TextMate and vim, and runs cross platform. Everything runs as expected on Ubuntu, not so much on Windows. Here’s what you need to do to get CoffeeScript highlighting and building:

  1. Install Node using the new Windows installer. This also installs npm.
  2. Open a cmd window
  3. Install CoffeeScript as you would normally: npm install -g coffee-script
  4. Reboot - all should be loaded into your PATH variable correctly
  5. For highlighting, git clone jashkenas’ coffee-script-tmbundle from GitHub into C:\Users\<User>\AppData\Roaming\Sublime Text 2\Packages\CoffeeScript
  6. At this point the building doesn’t work. Open up the build file: C:\Users\<User>\...\CoffeeScript\Commands\CoffeeScript.sublime-build and have it look like the following:
  "shell" : true,
  "cmd": ["coffee","-c","$file"],
  "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
  "selector": ""

Essentially you need to remove the “path” variable that’s there and add in the “shell” variable set to true so it runs from cmd.exe.