Can I use CoffeeScript instead of JS for node.js?

donald picture donald · Jan 13, 2011 · Viewed 65.4k times · Source

What are my restrictions if I want to code node.js and use CoffeeScript? Can I do anything I'd be able to do in JS?

Answer

David Tang picture David Tang · Jan 13, 2011

Yes, CoffeeScript simply compiles into pure JS, making it completely compatible with node.js.

To run CoffeeScripts on node, you can either:

  • Type coffee -c example.coffee to compile, followed by node example.js to run the compiled JS.
  • Simply type coffee example.coffee