根据这里的这个问题,我需要打电话request.setMaxListeners(0)
来解决所描述的问题。
当我尝试这样做时:
var request = require('request');
request.setMaxListeners(0);
我收到以下错误消息:
request.setMaxListeners(0);
^ TypeError: Object function request(uri, options, callback) { if (typeof uri === 'undefined') throw new Error('undefined is not a valid uri or options object.') if ((typeof options === 'function') && !callback) callback = options if (options && typeof options === 'object') {
options.uri = uri } else if (typeof uri === 'string') {
options = {uri:uri} } else {
options = uri }
options = copy(options)
if (callback) options.callback = callback var r = new Request(options) return r } has no method 'setMaxListeners'
at Object.<anonymous> (/home/vagrant/twitter/test.js:3: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:901:3
setMaxListeners
使用请求模块时如何正确调整默认值?
节点--版本:0.10.4
请求模块版本:2.16.6