如何解决“Cannot call method 'stream'”undefined"
How do I resolve "Cannot call method 'stream' of undefined"
我正在尝试使用ntwitter在putty终端上显示一些tweet。在根目录中安装了节点模块(express和ntwitter),当我尝试从根目录运行tweet_counter.js时,我得到了这个错误。
vagrant@precise32:~/app/Twitter$ node tweet_counter
/home/vagrant/app/Twitter/tweet_counter.js:7
twitter.stream(
^
TypeError: Cannot call method 'stream' of undefined
at Object.<anonymous> (/home/vagrant/app/Twitter/tweet_counter.js:7:9)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
//tweet_counter.js代码var ntwitter = require("ntwitter"),
credentials = require("./credentials.json"),
twitter;
// set up our twitter object
twitter = ntwitter(credentials);
// set up our twitter stream with three parameters,
// separated by commas
twitter.stream(
// the first parameter is a string
"statuses/filter",
// second parameter, an object containing an array
{ "track": ["awesome", "cool", "rad", "gnarly", "groovy"] },
// the third parameter is our callback for when the stream is created
function(stream) {
stream.on("data", function(tweet) {
console.log(tweet.text);
});
}
);
我很抱歉,我能够从您的相同程序中获取流,请确保您已正确安装了ntwitter,确保您从项目根目录安装,不需要使其全局,如果需要,只需保存为package.json中的依赖项。
你可以看到我在cmd下的输出:
RT @ToughAmanda: Watch @WWEToughEnough tonight at 8 pm est � Don't forget to download the app for some cool behind the scenes stuff & votin…
#ReCap -> #ReReplay #Exciting #Awesome
RT @DiegoNoJuuzou: #MTVHottest Demi Lovato https://t.co/4tmtAOiV2p
41 awesome things to do in London this week http://t.co/OxM1QfxTCm
@cieraira aku dh lama xminum cool blog. Sbb xde hg mungkin. Haha
@CampAmerica69听起来像一个很酷的夏令营,我从来没有参加过夏令营,哈哈:)@YankydoodlDandy:我喜欢的反派有末日博士、红骷髅、小丑(显然是)、康(这么棒的反派)和谜语人……太棒了!https://t.co/EDrQjEiO7I@obviouslyitsjoy: rad:rad的定义是俚语,指优秀的人或事。去看@BethanyMota的新视频吧!!这是太棒了! !我喜欢这些!!这真是个可爱的主意!!y贝丝! !): http://t.co/MNkKxTIh28捷豹路虎直接在挡风玻璃上投射驾驶数据http://t.co/8cX7pdQtRu通过@engadget #awesome #ilovescience #carsRT @bea_ker:"Don -这个名字真酷"
[紧张地出汗]是的,谢谢哈哈
相关文章:
- 铬:“;未捕获的语法错误:意外的标记:"
- 可以设置“;文件名"发生错误时显示的内联脚本标记的
- JS表单提交"无法使用Chrome数据保护程序加载此页面.尝试重新加载页面.调试信息:POST CISmtuK
- 检测电话窃听,即:<a href="电话:xxx">在UIWebview上
- 使用“+="操作人员
- //而不是在src=“”上使用http://"属性
- "未捕获的语法错误:意外的标记}"
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- "实例范围”;TypeScript类的getter/setter
- Javascript复选框函数:;缺少:在属性id之后"
- "“;变量未引用正确的对象
- "日期“;AJAX请求返回的类型值未定义
- 得到"TypeError:无法读取属性'filename'未定义的“;调用“npm start
- Soundcloud api"未捕获的类型错误:无法读取属性'uri'“未定义”;
- "工具提示"jQuery插件坏了
- "锻造;React中的表达式
- 图像可以从源<img src=""/>.TEXT可以在没有javascript的情况下从外部
- 如何提取“;href"最近列表项中的属性值
- CKEditor如何允许href="javascript:void(0)"在小部件中
- 插入“;img src"在javascript中