解决npm install代理报错

由 月林 发布
  | 2621 次浏览

前言

最近切换到Windows来写写Vue,拿起以前的项目敲npm install,结果报了代理错误,关掉系统代理后依旧。

Debugger attached.
npm ERR! code ENOTFOUND 
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz failed, reason: 
getaddrinfo ENOTFOUND registry.npmjs.org
npm ERR! network This is a problem related to network connectivity.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

解决问题

参考该文章:链接1 的解决办法:

1、代理设置

首先查看代理设置

npm config get proxy
npm config get https-proxy

如果返回值不为null则清除掉以前的代理设置:

npm config set proxy null
npm config set https-proxy null

如果返回值为null则进入到第2步骤;

2. 重新设置代理

npm config set registry http://registry.cnpmjs.org/

二、新的问题

按照该方法确实得以看见shell开始滚动花花绿绿的字符脚本代码了
但是接着又出现了问题:

npm WARN tar ENOENT: no such file or directory, open 'D:\XXXXXX\node_modules\.staging\vue-e9805497\src\platforms\web\runtime\directives\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\XXXXXX\node_modules\.staging\vue-e9805497\src\platforms\web\runtime\directives\model.js'
npm ERR! code ERR_TLS_CERT_ALTNAME_INVALID
npm ERR! errno ERR_TLS_CERT_ALTNAME_INVALID
npm ERR! request to https://registry.cnpmjs.org/@babel%2fplugin-transform-new-target failed, reason: Hostname/IP does not match certificate's altnames: Host: registry.cnpmjs.org. is not in the cert's altnames: DNS:r.cnpmjs.org

参考 链接2 该帖,找到解决方法:

npm config set strict-ssl false 

最终搞定!


版权属于:月琳cc
本文链接:https://kerrinz.com/archives/89.html
作品采用《知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议》进行许可,转载请务必注明出处!

仅有一条评论

  1. moposx
    moposx · 2020-11-21 12:56

    试试 Proxifier~

发表评论