title: Strange node.js error: TypeError: Object #<Object> has no method 'on'
body: <p>I'm trying to run a simple screen scraping app in node.js. The code is posted here:
  <a href="https://github.com/anismiles/jsdom-based-screen-scraper" rel="nofollow">https://github.com/anismiles/jsdom-based-screen-scraper</a>
  <a href="http://anismiles.wordpress.com/2010/11/29/node-js-and-jquery-to-scrape-websites/" rel="nofollow">http://anismiles.wordpress.com/2010/11/29/node-js-and-jquery-to-scrape-websites/</a></p>
  
  <p>The server starts up fine, but then when I run a query on it, I get the following error. Does anyone know why that is?</p>
  
  <pre><code>TypeError: Object #&lt;Object&gt; has no method 'on'
      at Object.&lt;anonymous&gt; (/Users/avishai/Downloads/anismiles-jsdom-based-screen-scraper-f0c79d3/searcher-server.js:9:10)
      at param (/Users/avishai/.node_libraries/.npm/connect/0.5.10/package/lib/connect/middleware/router.js:146:21)
      at param (/Users/avishai/.node_libraries/.npm/connect/0.5.10/package/lib/connect/middleware/router.js:157:15)
      at pass (/Users/avishai/.node_libraries/.npm/connect/0.5.10/package/lib/connect/middleware/router.js:162:10)
      at Object.router [as handle] (/Users/avishai/.node_libraries/.npm/connect/0.5.10/package/lib/connect/middleware/router.js:168:6)
      at next (/Users/avishai/.node_libraries/.npm/connect/0.5.10/package/lib/connect/index.js:218:15)
      at Server.handle (/Users/avishai/.node_libraries/.npm/connect/0.5.10/package/lib/connect/index.js:231:3)
      at Server.emit (events.js:45:17)
      at HTTPParser.onIncoming (http.js:1078:12)
      at HTTPParser.onHeadersComplete (http.js:87:31)
  </code></pre>
  
  <p>The function that appears to be throwing the error is:</p>
  
  <pre><code>function books(app){
      app.get('/:query', function(req, res, next) {
  
          res.writeHead(200, { 'Content-Type': 'text/html' });
  
          var rediff = require('./searcher-rediff');
          rediff.on('on_book', function(item){
              res.write(item + "&lt;br/&gt;");
          });
          rediff.on('completed', function(){
              res.end();
          });
          rediff.search(escape(req.params.query));
  
      });
  }
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Now I noticed that on the first request, I get this:</p>
  
  <pre><code>SyntaxError: Unexpected strict mode reserved word
      at Module._compile (module.js:369:25)
      at Object..js (module.js:380:10)
      at Module.load (module.js:306:31)
      at Function._load (module.js:272:10)
      at require (module.js:318:19)
      at Object.&lt;anonymous&gt; (/Users/avishai/Downloads/anismiles-jsdom-based-screen-scraper-f0c79d3/searcher.js:2:15)
      at Module._compile (module.js:374:26)
      at Object..js (module.js:380:10)
      at Module.load (module.js:306:31)
      at Function._load (module.js:272:10)
  </code></pre>