In CofeeScript I am creating a global object by doing this:
window.App =
init : ->
...
Running coffee -w app.coffee complains window is not defined and doesn’t rewrite the app.js file.
However, running coffee -c app.coffee compiles without a problem.
How can I get coffee -w to accept global window?
CoffeeScript version is 1.1.1 (from coffee -v)
Thanks!
If you want to watch a file and have it compiled you need to do:
Using only the
-wflag causes coffee to just run the script when it changes, as if you had run:In regards to the
window is not definederror, if you want to make your script runnable both in a browser and in node.js, then you can do this:Another useful flag combination is
-wpwhich just pipes the compile javascript to standard out each time you make a change to the file.