I have an app.js that is running express.js.
I wanna convert the code to coffeescript and thought about to create a app.coffee that I compile to app.js so I can run it with “node app.js”.
But then it hit me that I could just write that file in app.coffee and run it with “coffee app.coffee”.
Is this a better way? Can I run the server with “coffee” in production?
Yes you can use coffee command in production. I use it.
I can see two reasons why you would want to use app.js wrapper.
Oh, and you don’t need compile it. You can use a wrapper like this which compiles the coffee file transparently:
server.js:
This wrapper technique is especially useful if you want to use CoffeeScript in some hosted environments that does not directly support the CoffeeScript command. Such as Cloud 9 IDE. No need to fiddle with compiled js-files.