Windows 上的 CoffeeScript?

发布于 2024-09-08 03:48:49 字数 352 浏览 7 评论 0 原文

如何在 Windows 上尝试 CoffeeScript?

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

编辑:

自从我不久前问这个问题以来,出现了许多新的答案。 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

○闲身 2024-09-15 03:48:50

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

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

梅倚清风 2024-09-15 03:48:50

如果您想在 ASP.NET 应用程序中使用 CoffeeScript,则可以使用 此 HTTP 处理程序 为编译后的 CoffeeScript 代码提供服务。

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

臻嫒无言 2024-09-15 03:48:50

我自己还没有尝试过,但这似乎是一个答案。 (我已下载并安装,但尚未使用它。)

Visual Studio 2010 有一个插件,可以将 CoffeeScript 编辑添加到 VS(以及其他功能)。

它称为Web Workbench,并作为 vsix 下载。 (即可以从 VS UI 中下载。)

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.)

不美如何 2024-09-15 03:48:50

我只是将其作为对“我如何尝试”通常不在 Windows 上运行或尚未移植的工具的更普遍隐含问题的回答。使用运行类 UNIX 操作系统(例如 Linux 或 BSD)的虚拟机。

如果您有足够的 RAM 并且愿意学习足够的知识来解决问题,那么尝试开源软件就会变得更加容易。在 CoffeeScript 的情况下,您仍然可以在共享文件夹上执行诸如 --watch 之类的操作,并且大部分时间都保留在 Windows 环境中。您也不会用您尝试但不购买的工具和服务污染您的系统,如果您经常这样做,这会很方便。

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.

つ可否回来 2024-09-15 03:48:50

考虑使用 Chocolatey 在 Windows 上安装 http://chocolatey.org/packages/CoffeeScript

(安装 Chocolatey :https://github.com/chocolatey/chocolatey/wiki/Installation

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

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

海的爱人是光 2024-09-15 03:48:49

更新:请参阅我对此问题的其他答案,如何编译来自 .NET 的 CoffeeScript? 以获取更准确和最新的当前选项列表。

CoffeeScript-Compiler-for-Windows 效果很好。

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.

等风也等你 2024-09-15 03:48:49

也许这个问题发布时更复杂。但截至 2012 年,CoffeeScript 在任何平台上都易于使用。 说明对于 Windows、Mac 或 Linux 来说是相同的

  1. http://nodejs.org/
  2. 使用节点包管理器全局安装 CoffeeScript npm install -g Coffeescript 或本地 npm install --save-dev Coffeescript
  3. 在您最喜欢的文本编辑器中编写脚本。保存它,例如 hello.coffee
  4. 运行脚本 coffee hello.coffee 或编译它 coffee -c hello.coffee (到 你好.js

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)
雨夜星沙 2024-09-15 03:48:49

Node.js 目前在 Cygwin 上运行,因此这可能是在 Windows 上运行 CoffeeScript 的最佳选择。我会先尝试一下。

如果您有不同的首选 JavaScript 运行时,您可以使用预构建编译器 (extras/coffee-script.js)。例如,如果您将该脚本包含在网页上,则可以调用

CoffeeScript.compile(code);

... 来获取已编译的 JavaScript 字符串。

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

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
.

千纸鹤带着心事 2024-09-15 03:48:49

您可以在旧的 Window Script Host (cscript.exe) 下运行 CoffeeScript 编译器,它是自 Windows 98 以来 Windows 上的标准组件。不可否认,我不久前尝试过此操作,但没有成功,但我最近再次尝试,现在所有的标准 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/

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/

手长情犹 2024-09-15 03:48:49

您可以使用 jcoffeescript 作为命令行解决方案。

它使用基于 Java 的 javascript 引擎 (Rhino< /a>)并完成从 CoffeeScript 编译 coffee-script.js 的任务项目。这使得它可以将 CoffeeScript 编译器作为 Java 程序运行。

使用的命令(在 Windows/Linux 上)如下所示

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

:构建 Java 源代码(使用 IntelliJ Community Edition 以避免下载 Ant) 或 CoffeeScript v1.0 的预构建下载

我现在使用 jcoffeescript 代替 Ruby 解决方案(此处的另一个答案),因为这使我可以保留使用最新的 CoffeeScript 版本。

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.

回心转意 2024-09-15 03:48:49

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

之后,可以使用命令行(例如“coffee bla.coffee”)将您的 CoffeeScript 代码编译为 JavaScript 代码。

这样做的唯一缺点(不使用 Node.js)是 CoffeeScript 的 Ruby 版本仅限于版本 0.3.2 - 在转移到 Node.js 之前用 Ruby 编写的最后一个版本。

*但是,我在目前的工作和个人网页中仍然使用 Ruby 版本的 CoffeeScript,我没有看到太大的问题,因为这个版本的 CoffeeScript 已经相当成熟,并且大部分功能都列在 <可以使用 href="https://web.archive.org/web/20130403134845/http://jashkenas.github.com/coffee-script/" rel="nofollow noreferrer">CoffeeScript 网站。

*删除了最后这句话,这句话当时是正确的,但每隔几天就变得更加不正确; CoffeeScript 自 0.3.2 以来已经取得了长足的进步,并且已经超过了 1.1

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

高冷爸爸 2024-09-15 03:48:49

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

正如 jashkenas 建议的,我使用了预编译的 extras/coffee -script.js 文件。
Jurassic JavaScript 编译器一起使用已将其全部包装在一个库中: CoffeeSharp

该库还附带了一个命令行工具和用于 ASP.NET Web 开发的 HttpHandler。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文