English 中文(简体)
CoffeeScript on Windows?
原标题:

How can I try CoffeeScript on Windows?

The installation instructions are only for *nix: http://jashkenas.github.com/coffee-script/#installation

EDIT:

Since I asked this a while ago, many new answers have appeared. The number ( and quality ) of options for Windows users has been increased a lot. I "accepted" an answer a long time ago, then changed to other ( better ) answers as they came up, but I have now decided to not accept any answer, and let the community ( votes ) show which answers are best. Thanks to everyone for the input.

问题回答

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.

You can use a command-line version of CoffeeScript by installing Ruby on Windows and then installing the CoffeeScript Gem.

After that, the command-line is available, for example, coffee bla.coffee - to compile your CoffeeScript code down to JavaScript code.

The only disadvantage doing it this way (not using Node.js) is that the Ruby version of CoffeeScript is restricted to version 0.3.2 - the last version written in Ruby before it was moved over to Node.js.

*However, I still use the Ruby version of CoffeeScript in my current employment and my personal web page and I don t see much of a problem as this version of CoffeeScript is quite mature and most of the features listed on the CoffeeScript website can be used.

*striked out this last statement which was correct at the time but is becoming more incorrect every few days; CoffeeScript has now advanced a long way since 0.3.2 and is past 1.1

There re already bunch of answers here, but let me add mine. I wrote a .NET library for compiling CoffeeScript on Windows.

As jashkenas suggested, I ve used the pre-compiled extras/coffee-script.js file.
Together with the Jurassic JavaScript compiler I ve wrapped it all up in a single library: CoffeeSharp

The library also ships with a commandline tool and a HttpHandler for ASP.NET web development.

I ve used this one: https://bitbucket.org/maly/coffeescript-win/zealots looks working well, althouth you need to manually need to update coffee.script from 0.95 to 1.0.1.

Since node.js is now ported to Windows, this is actually pretty easy:

http://www.colourcoding.net/blog/archive/2011/09/20/using-coffeescript-on-windows.aspx

If you want to use CoffeeScript in an ASP.NET application then you can use this HTTP handler to serve compiled CoffeeScript code.

I haven t tried this myself yet, but it seems to be an answer. (I ve downloaded and installed but not used it yet.)

There s an add-in for Visual Studio 2010 that adds CoffeeScript editing to VS (among other things).

It s called Web Workbench and is downloaded as a vsix. (i.e. can be downloaded from within the VS UI.)

I m only putting this in only as an answer to the more general implied question for "How can I try" tools that don t normally run on Windows or have yet to be ported. Use a virtual machine running a UNIX-like OS such as Linux or BSD.

Provided you have enough RAM and are willing to learn enough to get around, it will make trying open source software a lot easier. In the CoffeeScript case you can still do things like --watch on a shared folder and remain in Windows land most of the time. You also won t pollute your system with tools and services you try and don t buy into, which is handy if you do that a lot.

Consider using Chocolatey to install http://chocolatey.org/packages/CoffeeScript on Windows.

(Installing Chocolatey : https://github.com/chocolatey/chocolatey/wiki/Installation)





相关问题
Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

get file icon for Outlook appointment (.msg)

I ve read Get File Icon used by Shell and the other similar posts - and already use SHFileInfo to get the associated icon for any given extension, and that works great. However, Outlook uses ".msg" ...

Identifying idle state on a windows machine

I know about the GetLastInputInfo method but that would only give me the duration since last user input - keyboard or mouse. If a user input was last received 10 minutes ago, that wouldn t mean the ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...

热门标签