0

i have a rather simple problem with running coffescript file which uses node js. After compiling this peace of code I can run it with node command, but when I use coffee command with original source require function returns undefined object

 require('util').print 'abc'
4

2 回答 2

2

I'm not sure I totally understand your question. You need to know two things:

  1. CoffeeScript wraps all of your code in an immediately invoked function expression
  2. CoffeeScript always returns

Look at your JavaScript output and see if something returns where you didn't expect it to.

于 2012-12-03T13:34:22.233 回答
2

I cannot reproduce this problem:

$ cat test.coffee 
require('util').print 'abc'

$ coffee test.coffee 
abc

I know it doesn't directly answer your question, but perhaps knowing that it works will steer you in the right direction. :)

于 2012-12-03T13:40:08.633 回答