1. 程式人生 > >npm 報錯unable to verify the first certificate

npm 報錯unable to verify the first certificate

HR script view 國內鏡像 number onf statistic lse sdn

npm總是報錯:unable to verify the first certificate

原創 2017年09月30日 11:06:10 https://blog.csdn.net/nicexibeidage/article/details/78140692?locationNum=2&fps=1

今天npm install總是報錯:unable to verify the first certificate(無法驗證第一證書),查了一下發現

As of February 27, 2014, npm no longer supports its self-signed certificates.

2014年2月27日,npm不再支持自簽名證書。

因為npm install走的是https協議,需要通過數字證書來保證的

解決方法1:

取消ssl驗證:npm config set strict-ssl false

如果還沒成功,則將npm源更換為國內鏡像:
npm config set registry http://registry.cnpmjs.org/
npm config set registry http://registry.npm.taobao.org/

解決方法2:

升級:npm install npm -g --ca=null
或者 npm config set ca=""

推薦使用方法1

npm 報錯unable to verify the first certificate