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. docker镜像push报错2. python django工程上传一张照片调用python方法时报错,请问如何处理?3. webpack - 从git上拉取vue项目,npm run dev时报错。4. node.js - Mac下用 hexo 部署blog, 执行 hexo deploy 命令报错5. node.js - cnpm安装electron报错please remove node_modules before retry!。6. angular.js - grunt server 报错7. node.js - webpack打包报错,求原因?求解决?8. android - 环信Easeui导入后启动报错UnsatisfiedLinkError9. dict - Python中dic写入txt报错:a bytes-like object is required, not ’str’10. mysql - 这条sql语句为什么加上where就报错?
