Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CoffeeScript on Windows?

People also ask

How do I run a CoffeeScript?

Open the Node. js command prompt. Browse through the path where you have saved the file and compile it using the -c option of the coffee command of the coffee command-line utility as shown below. On executing the above command, the CoffeeScript compiler compiles the given file (sample.

How do I know if CoffeeScript is installed?

The coffee and cake commands will first look in the current folder to see if CoffeeScript is installed locally, and use that version if so. This allows different versions of CoffeeScript to be installed globally and locally.

Is CoffeeScript better than JavaScript?

"Easy to read", "Faster to write" and "Syntactic sugar" are the key factors why developers consider CoffeeScript; whereas "Can be used on frontend/backend", "It's everywhere" and "Lots of great frameworks" are the primary reasons why JavaScript is favored.

Is CoffeeScript still a thing?

As of today, January 2020, CoffeeScript is completely dead on the market (though the GitHub repository is still kind of alive).


UPDATE: See my other answer to this question, How can I compile CoffeeScript from .NET? for a far more accurate and up-to-date list of the current options.

CoffeeScript-Compiler-for-Windows works well.


Maybe it was more complicated when this question was posted. But as of 2012, CoffeeScript is as easy to use on any platform. The instructions are the same for Windows, Mac, or Linux

  1. Install Nodejs from http://nodejs.org/
  2. Install CoffeeScript globally with the node package manager npm install -g coffeescript or locally npm install --save-dev coffeescript
  3. Write a script in your favourite text editor. Save it, say as hello.coffee
  4. Run your script coffee hello.coffee or compile it coffee -c hello.coffee (to hello.js)

Node.js runs on Cygwin these days, so that's probably your best bet with getting CoffeeScript running on Windows. I'd try that first.

If you have a different preferred JavaScript runtime, you can probably use the prebuilt-compiler (extras/coffee-script.js). For example, if you include that script on a webpage, you can call

CoffeeScript.compile(code);

... to get back the compiled JavaScript string.

UPDATE 2012-04-12: Cygwin is no longer needed to run Node on Windows. Microsoft worked with Joyent through 2H 2011 to improve node's support for Windows IOCP async IO. Node 0.6 was the first release of node to natively support Windows.


You can run the CoffeeScript compiler under good old Window Script Host (cscript.exe), a standard component on Windows since Windows 98. Admittedly I tried this a while back and it didn't work, but I tried again recently and now all the standard CoffeeScript tests compile just fine.

A bit of plumbing code using a *.wsf file and coffee-script.js is all you need. My code is on GitHub: https://github.com/duncansmart/coffeescript-windows

I blogged about it here: http://blog.dotsmart.net/2011/06/20/the-simplest-way-to-compile-coffeescript-on-windows/


You can use jcoffeescript as a command-line solution.

It uses a Java-based javascript engine (Rhino) and wraps up the task of compiling coffee-script.js from the CoffeeScript project. This allows it to run the CoffeeScript compiler as a Java program.

The command to use (on Windows/Linux) looks like this:

java -jar jcoffeescript-1.0.jar < foo.coffee > foo.js

You will need to download & build the Java source code (use IntelliJ Community Edition to avoid downloading Ant) or a pre-built download for CoffeeScript v1.0.

I now use jcoffeescript in place of the Ruby solution (another answer here), because this allows me to keep up with the latest CoffeeScript version.