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
解决方案
已解决,应该是cnpm的锅,用npm重新安装request模块,成功运行了