Windows 上的 CoffeeScript? ?

如何在 Windows 上尝试 CoffeeScript?

安装说明仅适用于 * nix: http://jashkenas.github.com/coffee-script/#installation

编辑:

自从我刚才问了这个问题之后,许多新的答案出现了。Windows 用户的选项数量(和质量)已经大大增加。很久以前,我“接受”了一个答案,然后改为其他(更好的)答案,但我现在决定不接受任何答案,让社区(投票)显示哪个答案是最好的。感谢大家的参与。

41961 次浏览

现在 Node.js 在 Cygwin 上运行,所以这可能是在 Windows 上运行 CoffeeScript 的最佳选择。我会先试试。

如果您有一个不同的首选 JavaScript 运行时,您可能会使用预构建编译器(附加/coffee-script)。Js).例如,如果在网页中包含该脚本,则可以调用

CoffeeScript.compile(code);

... to get back the compiled JavaScript string.

更新2012-04-12 : Cygwin 不再需要在 Windows 上运行 Node 2011年上半年与 Joyent 合作,改善节点对 Windows IOCP 异步 IO。 Node 0.6是 Node 0.6的第一个版本 原生支持 Windows .

If you want to use CoffeeScript in an ASP.NET application then you can use 这个 HTTP 处理程序 to serve compiled CoffeeScript code.

您可以通过 在 Windows 上安装 Ruby使用 CoffeeScript 的命令行版本,然后安装 CoffeeScript Gem

之后,可以使用命令行,例如,“ coffee bla.coffee”——将 CoffeeScript 代码编译成 JavaScript 代码。

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

You can use 咖啡脚本 as a command-line solution.

它使用了一个基于 Java 的 javascript 引擎(Rhino) ,并完成了从 CoffeeScript 项目编译 咖啡脚本的任务。这允许它以 Java 程序的形式运行 CoffeeScript 编译器。

要使用的命令(在 Windows/Linux 上)如下:

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

您需要下载并构建 Java 源代码(使用 IntelliJ Community Edition以避免下载 蚂蚁)或 pre-built download for CoffeeScript v1.0

I now use 咖啡脚本 in place of the Ruby solution (another answer here), because this allows me to keep up with the 最新的咖啡脚本 version.

更新: 请参阅我对这个问题的其他回答,如何从.NET 编译 CoffeeScript?有一个更准确和更新的当前选项列表。

CoffeeScript-Compiler-for-Windows 运行良好。

我用过这个 https://bitbucket.org/maly/coffeescript-win/zealots : 看起来工作得很好,尽管您需要手动更新 Coffee.script,从0.95更新到1.0.1。

这里已经有很多答案了,让我加上我的。我写了一个。NET 库,用于在 Windows 上编译 CoffeeScript。

作为 jashkenas 建议,我使用了预编译的 extras/coffee-script.js文件。
侏罗纪 JavaScript 编译器一起,我把它们都包装在一个库里: CoffeeSharp

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

您可以在 Windows 98以来的 Windows 标准组件 Window Script Host (cscript.exe)下运行 CoffeeScript 编译器。不可否认,我曾经试过这个方法,但是没有成功,但是最近我又试了一次,现在所有的标准 CoffeeScript 测试都编译得很好。

使用 *.wsf文件和 coffee-script.js编写一些管道代码就可以了。我的代码在 GitHub: https://github.com/duncansmart/coffeescript-windows

我在这里写博客: http://blog.dotsmart.net/2011/06/20/the-simplest-way-to-compile-coffeescript-on-windows/

我自己还没有尝试过,但这似乎是一个答案

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

它被称为 网络工作台,可以作为 vsix 下载(也就是说,可以从 VS UI 内部下载)

由于 node.js 现在已经移植到了 Windows 上,这实际上非常简单:

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

我只是把这只作为一个答案,更一般的隐含问题“我怎样才能尝试”的工具,通常不运行在 Windows 上或尚未移植。使用运行类 UNIX 操作系统(如 Linux 或 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.

也许这个问题发布的时候更复杂。但是到2012年,CoffeeScript 在任何平台上都很容易使用。对于 Windows、 Mac 或 Linux,指示是相同的

  1. http://nodejs.org/安装 Nodejs
  2. Install CoffeeScript globally with the node package manager npm install -g coffeescript or locally npm install --save-dev coffeescript
  3. 用你最喜欢的文本编辑器写一个脚本,保存为 hello.coffee
  4. 运行脚本 coffee hello.coffee或编译它 coffee -c hello.coffee(到 hello.js)