NPM 常见问题及解决方案

本文介绍使用 NPM 过程中常见的问题及解决方案。


1 unable to verify the first certificate

使用 npm installyarn install 时经常会遇到 unable to verify the first certificate,出现这个问题一般都是因为启用了代理。原因是 HTTPS 安全协议在发现服务端与客户端传输过程中多了代理转发,导致某些连接不受信,因此禁止连接。

解决方法:
(1) 配置淘宝镜像

npm config set registry http://registry.npm.taobao.org/ --global

(2) 配置 NPM 不做严格的 SSL 校验

npm config set strict-ssl false

(3) 配置环境变量,在【用户变量】中新增值为 0 的变量 NODE_TLS_REJECT_UNAUTHORIZED

NODE_TLS_REJECT_UNAUTHORIZED:0

2 UNABLE_TO_VERIFY_LEAF_SIGNATURE

在解决 unable to verify the first certificate 问题后,再次使用 yarn install 安装命令,出现 UNABLE_TO_VERIFY_LEAF_SIGNATURE

解决方法:
配置 YARN 不做严格的 SSL 校验

D:\>yarn config set "strict-ssl" false
yarn config v1.22.4
success Set "strict-ssl" to "false".
Done in 0.13s.

3 SSL certificate problem: unable to get local issuer certificate

解决方法:
配置 Git 不做 SSL 校验。

git config --global http.sslVerify false

4 fatal: unable to connect to github.com

解决方法:
配置 Git 使用 http 代替 https。

git config --global url.https://github.com/.insteadOf git://github.com/
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。