Search code examples
node.jscoffeescript

Nodejs Coffescript executing without translation and coffee command


Is here any way how to execute Coffescript script in Nodejs without translation to js or coffee command.

Something what will translate coffeesctipts on the fly, how will node request them.


Solution

  • First, do npm install coffee-script, then in your server.js (or app.js) do require('coffee-script') and any coffeescript files will automatically be compiled.

    This tutorial series goes into how to include coffeescript files so they will automatically be recompiled when they are edited:

    http://nodetuts.com/tutorials/16-introduction-to-coffeescript-and-nodejs.html#video

    http://nodetuts.com/tutorials/14-some-nodejs-tools.html#video