Is it possible to compile a string of coffeescript with the npm module, I have been looking everywhere and cannot seem to find any good answers.
2 Answers
If you're talking about the coffee command line utility, then yes you can (although it isn't too pretty):
echo "alert 'Hello World'" | coffee -sc
The code above compiles the CoffeeScript in the echo and outputs to STDOUT. If you want the compiled output in a file, you can do this:
echo "alert 'Hello World'" | coffee -sc > path/to/file.js
There's some good documentation on the command-line utility here: http://coffeescript.org/#usage
If you mean compiling a string within CoffeeScript code, the coffee-script module provides a compile function:
coffee = require 'coffee-script'
js = coffee.compile "alert 'Hello World'"