为什么我的node.js在下载页面时出现代码错误?

时间:2012-05-09 11:34:01

标签: http url node.js tcp

    var request = require('request');
    var url = 'http://pinterest.com';
    request({ 
        'method':'GET',
        'url':url,
    }, function(err, response, body){

    }); 

当我点击这个时,我得到:

[TypeError: Cannot read property 'url' of undefined]
TypeError: Cannot read property 'url' of undefined
    at new Cookie (/home/user/project/src/node_modules/request/vendor/cookie/indeprojectx.js:45:20)
    at /home/user/project/src/node_modules/request/main.js:434:33
    at Array.forEach (native)
    at Request.<anonymous> (/home/user/project/src/node_modules/request/main.js:428:46)
    at Request.emit (events.js:67:17)
    at IncomingMessage.<anonymous> (/home/user/project/src/node_modules/request/main.js:393:16)
    at IncomingMessage.emit (events.js:88:20)
    at HTTPParser.onMessageComplete (http.js:137:23)
    at Socket.ondata (http.js:1137:24)user

注意:我在EC2上。出于某种原因,这不适用于pinterest.com。它适用于Google.com和yahoo.com。我可以CURL pinterest.com就好了。

1 个答案:

答案 0 :(得分:1)

固定。我更新了模块并且工作正常。