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. angular.js - grunt server 報錯2. mysql建表報錯,查手冊看不懂,求解?3. java - idea 打包war包時候報錯?4. 加了頭部設置:header(’Content-type:text/html;charset=uft-8’); 報錯5. python - Scrapy中xpath用到中文報錯6. javascript - 使用webStorm通過git提交代碼push時報錯7. MySQL FOREIGN KEY 約束報錯8. java - IDEA使用JRebel插件啟動報錯9. javascript - 微信工作流 yo創建的項目 npm install node prebuild報錯10. python3.x - python中使用pymysql插入數據時當數據是字母字符串時報錯
