【React】npm install 报错 :npm ERR! code UNABLE_TO_VERIFY_LEAF_SIGNATURE npm ERR! errno UNABLE_TO_VERIFY

场景

1.github拉一个react项目
2.npm i或者yarn 时候
3.提示如下错误

错误:

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

原因:

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

解决方案:

关掉strict-ssl即可, 如下:

npm config set strict-ssl false 

用完之后恢复:

npm config set strict-ssl true

猜你喜欢

转载自blog.csdn.net/weixin_48200589/article/details/126973003