1、在node.js网站上下载node.exe: http://nodejs.org/#download
2、下载coffeescript: http://github.com/jashkenas/coffee-script/tarball/master
3、然后创建一个coffee.cmd文件,内容如下:
@echo off
"C:/Node/node.exe" "C:/CoffeeScript/bin/coffee" %*
测试
创建一个文件,如test.coffee,内容如下:
square = (x) -> x * x
进入 coffee.cmd所在的文件夹然后进行编译,我的test.coffee放在F:/test/test.coffee
coffee -c F:/test/test.coffee
运行后,如果一切正常的话,你会发现test.coffee同级目录下,将会多出一个test.js文件,内容如下:
<!-- lang: js -->
(function() {
var square;
square = function(x) {
return x * x;
};
}).call(this);
这样就说明我们的coffee安装成功了! 此命令行有以下参数可供使用:
<!-- lang: cpp -->
-c, --compile compile to JavaScript and save as .js files
-o, --output [DIR] set the directory for compiled JavaScript
-j, --join [FILE] concatenate the scripts before compiling
-b, --bare compile without the top-level function wrapper
-v, --version display CoffeeScript version
-h, --help display a list of available options