Events.js: 85 throw er; // Unhandled event 'error'

I'm trying to set up a twitter application, and currently I'm stuck with the following error:

$ node twitter.js events.js:85 throw er; // Unhandled 'error' event ^ SyntaxError: Unexpected token U at Object.parse (native) at EventEmitter.receive (/Users/user/Documents/twitter/node_modules/twitter/lib/parser.js:40:21) at IncomingMessage.<anonymous> (/Users/user/Documents/twitter/node_modules/twitter/lib/twitter.js:207:14) at IncomingMessage.emit (events.js:129:20) at readableAddChunk (_stream_readable.js:163:16) at IncomingMessage.Readable.push (_stream_readable.js:126:10) at HTTPParser.parserOnBody (_http_common.js:132:22) at TLSSocket.socketOnData (_http_client.js:317:20) at TLSSocket.emit (events.js:107:17) at readableAddChunk (_stream_readable.js:163:16) MBPro:twitter $ 

Syntax error? I do not understand.

Twitter.js Code:

 var tweet = require('twitter'), twitter = new tweet({ consumer_key: '', consumer_secret: '', access_token_key: '', access_token_secret: '' }); var count = 0, util = require('util'); twitter.stream('filter', {track: 'test'}, function(stream){ stream.on('data', function(data) { console.log(util.inspect(data)); stream.destroy(); process.exit(0); }); }); 
+7
javascript
source share
2 answers

This is a bug in the twitter module. The module must check the value of the HTTP Content-Type response before attempting to parse the response as JSON.

This is an actual issue for github.

+2
source share

I was getting the same error, and this happened because the mongodb instance did not start. I started mongodb in my osx with;

 sudo mongod 
-one
source share

All Articles