I'm trying to setup a twitter app and I'm currently stuck on the following error:
我正在尝试设置一个Twitter应用程序,我目前卡在以下错误:
$ 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 $
Synthax error? I don't understand.
Synthax错误?我不明白。
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);
});
});
2 个解决方案
#1
2
This is a bug in the twitter
module. The module should be checking the HTTP response's Content-Type
header value before trying to parse the response as JSON.
这是twitter模块中的一个错误。在尝试将响应解析为JSON之前,模块应检查HTTP响应的Content-Type标头值。
Here is the relevant issue on github.
这是github上的相关问题。
#2
-1
I was getting the same error and it was because by mongodb instance was not running. I started mongodb in my osx with;
我得到了同样的错误,这是因为mongodb实例没有运行。我在我的osx中开始使用mongodb;
sudo mongod
#1
2
This is a bug in the twitter
module. The module should be checking the HTTP response's Content-Type
header value before trying to parse the response as JSON.
这是twitter模块中的一个错误。在尝试将响应解析为JSON之前,模块应检查HTTP响应的Content-Type标头值。
Here is the relevant issue on github.
这是github上的相关问题。
#2
-1
I was getting the same error and it was because by mongodb instance was not running. I started mongodb in my osx with;
我得到了同样的错误,这是因为mongodb实例没有运行。我在我的osx中开始使用mongodb;
sudo mongod