Thursday, December 6, 2012

Installing and Running CoffeeScript in Windows

Some web frameworks such as Ruby on Rails3 and the Play! framework4 support CoffeeScript by default. If you’re using such a framework, none of this installation is necessary; just place your .coffee files in the correct place and the framework will compile them for you.

Installation Steps
  • First of all, install Node.js from http://nodejs.org/download/.
  • Once the install is complete, you should be able to run Node.js from your terminal
    via node command.
    • node --help
  • The next step is to install coffee via Node.js supported NPM (Node's Package Manager). 
  • To install the coffee script module, use the following command:
    • npm install -g coffee-script
  • This will fetch the module and make it available via Node.js.
  • Open new command prompt and check if the coffee script is installed properly by using the following command:
    • coffee --help
  • Now you can save your coffee script code as .coffee file and run the files using the following command:
    • coffee FileName.coffee
  • To compile the coffeescript into Javascript, use -c (compile) flag:
    • coffee -c FileName.coffee
    • This generates a JavaScript file of the same name in the same directory, but with the .js extension.

No comments: