2014-01-21 54 views
3

您好我是新來的節點JS,我試圖按照書中的樣品,並嘗試做NPM安裝我收到以下錯誤時:NPM安裝引發錯誤錯誤:無效的協議

任何幫助將是高度讚賞

C:\Developer\NODE_JS>npm install 
    npm WARN package.json [email protected] No repository field. 
    npm WARN package.json [email protected] No README data 
    npm http GET http://registry.npmjs.org/socket.io 
    npm http GET http://registry.npmjs.org/mime 
    npm http GET http://registry.npmjs.org/socket.io 
    npm http GET http://registry.npmjs.org/mime 
    npm http GET http://registry.npmjs.org/socket.io 
    npm http GET http://registry.npmjs.org/mime 
    npm ERR! Error: Invalid protocol 
    npm ERR!  at Request.init (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:335:51) 
    npm ERR!  at new Request (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:99:8) 
    npm ERR!  at request (C:\Program Files\nodejs\node_modules\npm\node_modules\request\index.js:55:11) 
    npm ERR!  at RegClient.makeRequest (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:211:13) 
    npm ERR!  at RegClient.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:117:17) 
    npm ERR!  at null._onTimeout (C:\Program Files\nodejs\node_modules\npm\node_modules\retry\lib\retry_operation.js:32:10) 
    npm ERR!  at Timer.listOnTimeout [as ontimeout] (timers.js:110:15) 
    npm ERR! If you need help, you may report this *entire* log, 
    npm ERR! including the npm and node versions, at: 
    npm ERR!  <http://github.com/isaacs/npm/issues> 

    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" 
    npm ERR! cwd C:\Developer\NODE_JS 
    npm ERR! node -v v0.10.24 
    npm ERR! npm -v 1.3.21 
    npm ERR! 
    npm ERR! Additional logging details can be found in: 
    npm ERR!  C:\Developer\NODE_JS\npm-debug.log 
    npm ERR! not ok code 0 

我的節點JS的配置是

C:\Developer\NODE_JS>npm config list 
; cli configs 
registry = "http://registry.npmjs.org/" 

; userconfig C:\Users\<uname>\.npmrc 
https-proxy = "proxy.<comp>.com:8080" 
proxy = "proxy.<comp>.com:8080" 
registry = "http://registry.npmjs.org/" 

; builtin config undefined 
prefix = "C:\\Users\\puppalap\\AppData\\Roaming\\npm" 

; node bin location = C:\Program Files\nodejs\\node.exe 
; cwd = C:\Developer\NODE_JS 
; HOME = C:\Users\<uname> 
; 'npm config ls -l' to show all defaults. 
+0

如果您嘗試npm install請求然後再次運行npm install,會發生什麼? – ashack

回答

1

問題是由於設置了windows http_proxy環境變量;而我不使用代理。

如果設置了http_proxy,將顯示命令提示符中的以下命令;

set http 

如果設置刪除變量與下面的命令和問題解決。

set http_proxy= 

Above command will remove the http_proxy from the current command line. However, if you need to permanently remove it, just remove it from System Properties>Advanced Tab>Environment Variables dialog box.

+0

H:\ himanshi> npm config list ; cli configs user-agent =「npm/3.10.10 node/v6.10.1 win32 x64」 ; userconfig C:\ Users \ Mahendra \ .npmrc registry =「http://registry.nmpjs.org/」 regitry =「http://regitry.npmjs.org」 strict-ssl = false ; builtin config undefined prefix =「C:\\ Users \\ Mahendra \\ AppData \\ Roaming \\ npm」 ;節點bin位置= C:\ Program Files \ nodejs \ node.exe ; cwd = H:\ himanshi ; HOME = C:\ Users \ Mahendra ; 「npm config ls -l」顯示所有的默認值。 –

+0

我得到了這個,如何解決空協議問題 –

+0

你的答案救了我從溺水,對不起我只有投票 – EaB

0

想和大家分享的方法,我也跟着的方式,尋求解決辦法,

My error: was ERR! Error: Invalid protocol : myusername:

[以前代理的用戶名]

在我的.npmrc文件 包含註冊表=「http://registry.npmjs.org/」 和其他變量[前綴,密碼,主頁]

因爲我不是代理的背後,除去代理變量 還是得到了同樣的錯誤

when looked into request.js[/usr/lib/node_modules/npm/node_modules/request/request.js] file it is using the old proxy values

因此,我加入的init()request.js的

self.proxy="http://registry.npmjs.org/" //at the start of method 

然後它開始行加工!!!

PS:一旦安裝命令後,刪除此行,它繼續工作。 嘗試這個,如果沒有其他選項正在工作