npm install 报错 :npm ERR! code UNABLE_TO_VERIFY_LEAF_SIGNATURE npm ERR! errno UNA

523 阅读1分钟

错误

npm ERR! code UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm ERR! errno UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm ERR! request to https://registry.npmjs.org/express failed, 
reason: unable to verify the first certificate

image.png

原因

无法验证第一证书,因为npm install走的是 https 协议,需要通过数字证书来保证的,所以,取消ssl验证

解决方案

关掉strict-ssl即可, 如下:

npm config set strict-ssl false 

用完之后恢复(我没恢复):

npm config set strict-ssl true