coffeescript: suppress "ReferenceError"
backbone.js, coffeescript, javascript, jquery
Solution
The options must go before the file, e.g.:
coffee -cw script.coffee
Otherwise, it will try to run `script.coffee` right then and there as a Node.js script, passing it the options `-c` and `-w`. That's not what you want; if you want the CoffeeScript compiler to get the options, it's got to be before the file name.
Problem
Currently working through this tutorial on using Backbone.js with coffeescript. Leveraging the following `index.html` file: ``` <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>CoffeeScript, Meet Backbone.js: Part N</title> <link rel="stylesheet" href="style.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script> <script src="http://ajax.cdnjs.com/ajax/libs/underscore.js/1.1.6/underscore-min.js"></script> <script src="http://ajax.cdnjs.com/ajax/libs/backbone.js/0.3.3/backbone-min.js"></script> <script type="text/javascript" src="./index.js"></script> </head> <body> <header> <h1>CoffeeScript, Meet Backbone.js: Part 1</h1> </header> </body> </html> ``` which loads an `index.js` file after loading Backbone, jQuery, etc from a cdn. Hoping to work within a `script.coffee` file that I'd like to have automatically compile into the `script.js` file loaded by `index.html` above by running something like `coffee script.coffee -c -w.` Trouble is, I'm getting `ReferenceError`s when I try to run the above command on the following `script.coffee` file: ``` jQuery -> class ListView extends Backbone.View el: $ 'body' initialize: -> _.bindAll @ @render() render: -> $(@el).append '<ul><li>Hello, Backbone!</li></ul>' list_view = new ListView ``` For instance: ``` ReferenceError: jQuery is not defined ... ``` because, clearly, jQuery is being loaded in the `index.html` file. Is there a way to suppress the error reporting from the coffeescript compiler so that it just converts the code without the error?