javascript - nodejs使用require(’request’)模块发送数据,报错
问题描述
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
问题解答
回答1:已解决,应该是cnpm的锅,用npm重新安装request模块,成功运行了
回答2:我试了一下,是没有发现问题的,你是用webstorm的调试工具运行的吗? 或者可以尝试一下重新安装模块,再用命令行运行试一下。只看到一个跟你一样问题的 看 Stack Overflow里面 贴上连接参考一下,还有感觉你的报错信息也不完整建议贴全一点https://stackoverflow.com/que...
是不是 npm 设 proxy 了
回答4:是:还是:?
相关文章:
1. javascript - export 导出后方法报错undefined2. node.js - 使用npm start报错:Cannot find module ’v8flags’3. mysql 主主同步,数据库 B 报错4. android - gradle配置recyclerview引用是报错,提示安装对应的Support Repository,请问如何解决。5. android - 环信Easeui导入后启动报错UnsatisfiedLinkError6. docker Toolbox在win10 家庭版中打开报错7. 报错 Fatal error: Cannot declare function Demo2 est because the name is already in use in8. mysql - thinkphp3.2 csv批量导入上万条数据时报错超时,请问有什么好的办法处理?9. Phpstorm搭配Sqlsever2008实现PDO连接报错10. 为啥我的一直报错
