2014-11-18 17 views
19

Wenn ich versuche grunt über npm zu installieren, erhalte ich einen folgenden Fehler:NodeJS NPM Proxy Fehler bei der Installation Grunzen

C:\Program Files\nodejs\node_modules\npm>npm install -g grunt 
npm ERR! network connect ETIMEDOUT 
npm ERR! network This is most likely not a problem with npm itself 
npm ERR! network and is related to network connectivity. 
npm ERR! network In most cases you are behind a proxy or have bad network settings. 
npm ERR! network 
npm ERR! network If you are behind a proxy, please make sure that the 
npm ERR! network 'proxy' config is set properly. See: 'npm help config' 

npm ERR! System Windows_NT 6.1.7601 
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "grunt" 
npm ERR! cwd C:\Program Files\nodejs\node_modules\npm 
npm ERR! node -v v0.10.33 
npm ERR! npm -v 1.4.28 
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!  C:\Program Files\nodejs\node_modules\npm\npm-debug.log 
npm ERR! not ok code 0 

Ich bin mit Enterprise Proxy-Konfigurationen, und ich glaube, dass ich m diesen Fehler wegen seiner Konfigurationen zu haben. Was muss ich ändern, um grunt erfolgreich installieren zu können?

Antwort

20

Sie müssen die NPM-Konfigurationsdatei konfigurieren, kann dies im Terminal erfolgen:

npm config set proxy http://proxy.company.com:8080 

npm config set https-proxy http://proxy.company.com:8080 

Ihr Fehlerprotokoll ‚npm ​​Hilfe config‘ zu sehen, legt nahe, so dass ich denke, das Problem von dort kommt.

Wenn Sie eine Verbindung mit mehr Erklärung siehe this blog entry (es gibt viel mehr ist)

Viel Glück!

+3

Nur eine Warnung an andere Benutzer, vergessen Sie nicht, den http: // Teil hinzuzufügen! – rory

+1

arbeitete für mich danke –

9

Wenn Sie hinter einem Proxy in einem "Fenster" Domäne arbeiten, fügen Sie den Domain-Namen in die Proxy-URL:

npm config set proxy http://domain%5Cuser:[email protected]:8080 
npm config set https-proxy http://domain%5Cuser:[email protected]:8080 

Sie müssen den umgekehrten Schrägstrich als http uri String kodieren:% 5C

Wenn Ihr Benutzername oder Passwort Sonderzeichen enthält, müssen diese Zeichen ebenfalls codiert werden. Beachten Sie, dass diese kritischen Informationen als Klartext in der npm-Konfigurationsdatei (% HOME% \. Npmrc) gespeichert werden. Es könnte auch notwendig sein, die npm Registrierung auf die http-Quelle zu verweisen:

npm config set registry "http://registry.npmjs.org" 
npm config set strict-ssl false 
3

Diese Konfiguration funktioniert für mich. Sie müssen Ihre HTTP- und HTTPS-Ports überprüfen (normalerweise 80 bzw. 443), aber in meinem Fall verwende ich Port 80 für beide.

npm config set proxy http://user:[email protected]:80 

npm config set https-proxy http://user:[email protected]:80 

Sie können Ihre Proxy-Einstellungen von get Befehl

npm config get proxy 

npm config get https-proxy 
2

Ich hatte das gleiche Problem vor, weil ich mit Proxy-Konfiguration aus Versehen wie diese gespielt :

npm config set proxy http://localhost:8080/ npm config set https-proxy http://localhost:8080/ npm config set strict-ssl false

das NPM-Client gemacht versucht localhost zu schlagen: 8080 das Modul statt dem richtigen Internet-Endpunkt zu ziehen.

so nach ein paar Tagen der Frustration besuchte ich diesen Link

https://docs.npmjs.com/cli/config

dann laufen

npm config edit 

, die eine Datei in die Datei geöffnet ich diese drei Zeilen entfernt i oben gegeben, dann Alles hat gut funktioniert.

1

Sie können dies in cmd laufen

npm config set <key> <value> [-g|--global] 
npm config get <key> 
npm config delete <key> 
npm config list 
npm config edit 
npm get <key> 
npm set <key> <value> [-g|--global] 

npmrc.txt laufen Sie Ihren Link und Port

proxy =http://proxy.company.com:8080 

https-proxy = http://proxy.company.com:8080 

reference

Verwandte Themen