javascript - nodejs使用require('request')模組發送數據,報錯
女神的闺蜜爱上我
女神的闺蜜爱上我 2017-07-03 11:42:31
0
4
982
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

女神的闺蜜爱上我
女神的闺蜜爱上我

全部回覆(4)
阿神

已解決,應該是cnpm的鍋,用npm重新安裝request模組,成功運行了

漂亮男人

我試了一下,是沒有發現問題的,你是用webstorm的調試工具運行的嗎?
或可以嘗試重新安裝模組,再用命令列運行試行。
只看到一個跟你一樣問題的 看 Stack Overflow裡面
貼上連接參考一下,還有感覺你的報錯信息也不完整建議貼全一點
https://stackoverflow.com/que...

为情所困

是不是 npm 設 proxy 了

仅有的幸福

是:還是:?

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!