[英]not able to install node_modules
我正在嘗試安裝node_module但收到以下錯誤:
例如:npm install grunt-preprocess
D:\grunt_pre>npm install grunt-preprocess
npm http GET https://registry.npmjs.org/grunt-preprocess
npm http GET https://registry.npmjs.org/grunt-preprocess
npm http GET https://registry.npmjs.org/grunt-preprocess
npm ERR! Error: connect ETIMEDOUT
npm ERR! at errnoException (net.js:901:11)
npm ERR! at Object.afterConnect [as oncomplete] (net.js:892:19)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "grunt-preprocess"
npm ERR! cwd D:\grunt_pre
npm ERR! node -v v0.10.15
npm ERR! npm -v 1.3.5
npm ERR! syscall connect
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! D:\grunt_pre\npm-debug.log
npm ERR! not ok code 0
注冊表URL指向https
,您可以嘗試更改它
npm config set registry="http://registry.npmjs.org/"
然后嘗試安裝模塊。 您可能在阻止安全( https
)連接的代理后面
如果它不起作用,那么您可以手動嘗試從此處下載您嘗試安裝的模塊的當前版本
並運行命令npm install grunt-preprocess-2.3.0.tgz
我也有ETIMEDOUT
錯誤,並且能夠通過禁用路由器的防火牆,重新啟動它來解決問題,最重要的是,使用以下npm命令配置同時連接的數量:
npm set maxsockets 3
這將最大連接數設置為3,而不是默認值50.自npm@3.8.0起,CLI已允許此選項。 有關詳細參考,請參閱此鏈接 。
我得到完全相同的東西。 模塊存在,但實際的下載存儲庫已關閉,或者此刻npm存在問題。 幾天后再試一次或將其報告給github鏈接。
編輯:
您收到的錯誤是服務器或連接超時。 可能是因為您在阻止連接的防火牆/代理后面。
嘗試@ Canmah的答案。 如果它沒有幫助嘗試檢查您的代理配置。
如果有代理,請按照下面的說明更新npm注冊表,然后嘗試安裝節點模塊。
@ the command prompt update the
npm config set proxy <proxyserver>:<port>
這可能是模塊bin-wrapper的一個問題,它不尊重代理,這就是你在嘗試下載時看到ETIMEDOUT錯誤的原因。
要解決此問題,您可以設置環境變量HTTP_PROXY和/或HTTPS_PROXY。
適用於Windows / Linux。
修復中的代碼片段:
var proxyServer = process.env.HTTPS_PROXY ||
process.env.https_proxy ||
process.env.HTTP_PROXY ||
process.env.http_proxy;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.