女神的闺蜜爱上我2017-07-03 11:42:31 0 4 460
var request = require('request');
request('http://www.baidu.com', function (error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); // Print the HTML for the Google homepage.
});
这是官网上的实例,但是我这边报错。error: Error: Invalid protocol: null
不知道什么协议的原因
官方githubrequest
阿神 2017-07-03 11:44:314楼
已解决,应该是cnpm的锅,用npm重新安装request模块,成功运行了
赞 +0添加回复
漂亮男人 2017-07-03 11:44:313楼
我试了一下,是没有发现问题的,你是用webstorm的调试工具运行的吗?
或者可以尝试一下重新安装模块,再用命令行运行试一下。
只看到一个跟你一样问题的 看 Stack Overflow里面
贴上连接参考一下,还有感觉你的报错信息也不完整建议贴全一点
https://stackoverflow.com/que...
赞 +0添加回复
为情所困 2017-07-03 11:44:312楼
是不是 npm 设 proxy 了
赞 +0添加回复
仅有的幸福 2017-07-03 11:44:311楼
是:还是:?
赞 +0添加回复