0

I use coffee script to writing my node.js app. When I write an .coffeescript file and run it. It will compile into top-level function javascript and this make my code didn't run.

Ex:

app.coffee

console.log "Hello world";

Will automatically compile into

(function() {
    console.log("Hello world");
}).call(this)

And this make node app.coffee didn't run.

Can you help me whenever I run node app.coffee it will compile my coffeescript with -bare option?

fracz
  • 20,536
  • 18
  • 103
  • 149
Minh Thành
  • 143
  • 9
  • If you're getting errors, what are they? If by "not run" you mean "doesn't produce any output", say that specifically. – tadman Jun 06 '16 at 06:23

1 Answers1

3

Do you run cofeescript with node app.coffee?

According to answers to this question it is impossible. You have to either compile it first and then run, i.e.

coffee -c app.coffee
node app.js

or use the coffee to run it for you, i.e.

coffee app.coffee

Nevertheles, I can't see how the wrapper function generated by coffee could "make the app did not run".

Community
  • 1
  • 1
fracz
  • 20,536
  • 18
  • 103
  • 149