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. android - 哪位大神知道java后臺的api接口的對象傳到前端后輸入日期報錯,是什么情況?求大神指點2. python - Flask寫的注冊頁面,當注冊時,如果填寫數據庫里有的相同數據,就報錯3. 沒有輸出結果,也沒有報錯信息4. javascript - jquery ajax 用jsonp的方式跨域訪問,為什么報錯5. javascript - vue: 父組件給子組件傳遞數據,子組件接收到了,但是報錯,怎么解決?6. python - 啟動Eric6時報錯:’qscintilla_zh_CN’ could not be loaded7. javascript - vue項目 npm run dev報錯8. fetch_field_direct()報錯9. 網頁爬蟲 - python3.4.1 request模塊報錯 ’list’ object has no attribute ’get’10. dict - Python中dic寫入txt報錯:a bytes-like object is required, not ’str’
