2

How can i process a coffeescript code directly into javascript in node.js ?

maybe i could use the coffee compiler using child_process.exec/spawn/fork but is there a direct way ? like loading a library (that ships with the coffee package when it's installed with npm) and passing code to it, that returns the compiled code directly ?

2 Answers 2

4

You can do npm install coffee-script and then just put var coffee = require('coffee-script'); to get access to the coffee.compile function which will do what you want.

Sign up to request clarification or add additional context in comments.

1 Comment

Indeed; also, doing require('coffee-script'); will register the .coffee file extension, so you will then be able to require CoffeeScript files.
-1

did you have a look at Express? It supports coffeekup template engine too.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.