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. composer包时报错2. MySQL的合计函数这里为什么报错?3. javascript - 网上找的bootstrap模板,复制到myeclipse之后,js为什么会报错?4. 网页爬虫 - python urlopen 报错 timeout: timed out5. 导入数据库文件报错 #1215 - Cannot add foreign key constraint6. tp5.0|php8.0 在window系统上写定时任务,执行报错7. mysql日期类型默认值’0000-00-00’ 报错8. 导入phpmyadmin的时候报错了9. javascript - vux的confirm,x-number报错。。说我未定义正确,但是官方网站就是这样写的诶。10. python - 启动Eric6时报错:’qscintilla_zh_CN’ could not be loaded
