2013-12-23 57 views
24

我試圖在Ubuntu中安裝Phonegap。 NodeJS的安裝是成功的,但是我無法安裝Phonegap本身。這裏是終端的錯誤輸出:錯誤:UNABLE_TO_VERIFY_LEAF_SIGNATURE Phonegap安裝

[email protected]:~$ sudo npm install -g phonegap 
npm http GET https://registry.npmjs.org/phonegap 
npm http GET https://registry.npmjs.org/phonegap 
npm http GET https://registry.npmjs.org/phonegap 
npm ERR! Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE 
npm ERR!  at SecurePair.<anonymous> (tls.js:1350:32) 
npm ERR!  at SecurePair.EventEmitter.emit (events.js:92:17) 
npm ERR!  at SecurePair.maybeInitFinished (tls.js:963:10) 
npm ERR!  at CleartextStream.read [as _read] (tls.js:463:15) 
npm ERR!  at CleartextStream.Readable.read (_stream_readable.js:320:10) 
npm ERR!  at EncryptedStream.write [as _write] (tls.js:366:25) 
npm ERR!  at doWrite (_stream_writable.js:219:10) 
npm ERR!  at writeOrBuffer (_stream_writable.js:209:5) 
npm ERR!  at EncryptedStream.Writable.write (_stream_writable.js:180:11) 
npm ERR!  at write (_stream_readable.js:573:24) 
npm ERR! If you need help, you may report this log at: 
npm ERR!  <http://bugs.debian.org/npm> 
npm ERR! or use 
npm ERR!  reportbug --attach /home/test/npm-debug.log npm 

npm ERR! System Linux 3.11.0-14-generic 
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "phonegap" 
npm ERR! cwd /home/test 
npm ERR! node -v v0.10.15 
npm ERR! npm -v 1.2.18 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  /home/test/npm-debug.log 
npm ERR! not ok code 0 

任何幫助,將不勝感激。

回答

64

我得到了同樣的錯誤,因爲我在公司防火牆/代理後面,並且我的連接已通過代理的證書。

在命令行中運行:

npm config set strict-ssl false 

注:這是盲目地接受信任或無效的SSL證書,這是命令的作用不是最好的做法(關閉證書檢查)。您可以運行

npm config set strict-ssl true 

將其重新打開。

裁判:https://thomashunter.name/blog/npm-ssl-errors/

+0

它適合我。 – SaXeTz

+0

@jdmonty非常感謝,這對我也很有用 –

+0

謝謝..它也適用於使用npm安裝Angular CLI。 – kmwtnarendra

3

運行

npm config set strict-ssl false 

解決我的問題。

我使用Vagrant(Linux精確32 Ubuntu)和Windows 7作爲主機。

感謝

8

這可以固定而不禁用嚴格SSL,但它是不平凡的。

找到實際使用的證書,可能你是behind a corporate SSL intercepting proxy。您可能能夠使用瀏覽器,某些CLI工具等。我最終在Windows中運行certmgr.msc,因爲證書通過組策略分發並導出爲p7b文件。

轉換如果有必要的證書,我用的OpenSSL工具從P7B轉換爲PEM(又名.CRT)

openssl pkcs7 -print_certs -inform DER -in /mnt/adam/certs/my-company-root.p7b -outform PEM -out my-company-root.crt 

合併,如果有一個以上的證書,到一個單一的PEM在證書文件

文件, taking care to order from leaf to root.

cat my-company-leaf.crt my-company-intermediate.crt my-company-root.crt > my-company-single.crt 

配置 NPM

npm config set cafile my-company-single.crt 

(或全球)

sudo npm config set -g cafile my-company-single.crt 
-1

運行

npm config set strict-ssl false 

爲我工作。解決了我的問題....