tl;dr: You can compile CoffeeScript on Windows with zero third-party dependencies.

A while back I did a post on running the LESS.js compiler on Windows using the venerable and ubiquitous Window Script Host (WSH: providing JavaScript console scripting since Windows 98... when John Resig was still in 8th grade). At the time I tried something similar to generate JavaScript from the wonderful CoffeeScript language, but I couldn't get it working due to what I assumed were shortcomings in WSH's JScript engine. There are plenty of other options out there for compiling CoffeeScript, but incur various third-party dependencies as detailed in this StackOverflow question.

But on a whim the other day I revisited it and thankfully now it does work on plain old WSH without any coaxing (not sure what changed, or what I was doing wrong last time). I took the full browser-based coffee-script.js and wrapped it with a simple *.wsf and batch file to handle command-line options.


It's on github, natch: https://github.com/duncansmart/coffeescript-windows


To use it, invoke coffee.cmd like so:

coffee input.coffee output.js

You can also pipe to and from it if you are so inclined via stdin/out. Errors are written to stderr.

In the test directory there's a version of the standard CoffeeScript tests which can be kicked off using test.cmd. Note that the test just attempts to compile the standard set of  *.coffee test files but doesn't execute them.

Hope it helps; comments appreciated!


Comment by Nick Perkins

Great Solution!...I had no idea that you could just run javascript programs in Windows like this. More people should use coffeescript because it's awesome, and this sounds like a great way for Windows users to start programming in coffeescript. Thanks very much.

Nick Perkins
Comment by Mike

Looks neat but as newbie to nodejs/coffee, I'm not sure what to do with the files. For example, I have nodejs installed and working from a usb drive in a Win7 environment. I installed coffee-script via npm and there is an extensive install directory. Do I put _all_ your files in the node_modules directory or in a separate directory? TIA for any guidance.