解决npm install网络超时问题

4,761 阅读1分钟

错误信息

主要信息:

request to registry.npmjs.org/vue failed, reason: connect ETIMEDOUT IPV6地址:443

详细信息

pm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! network request to https://registry.npmjs.org/vue failed, reason: connect ETIMEDOUT 2001:0DB8:0000:0023:0008:0800:200C:417A:443
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
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'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administator\AppData\Roaming\npm-cache\_logs\2020-08-04T07_11_33_323Z-debug.log

连接超时问题

原因

npm不支持IPV6地址,因此需要将本地IP地址设置为IPV4地址

参考链接:github.com/npm/npm/iss…

解决方案

1、首先按Win+R打开运行,输入regedit,按回车打开注册表编辑器。

2、找到 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters ,然后查看右边有没有一个叫DisabledComponents的值,如果没有的话就新建一个DWORD值,填这个名字。

3、双击DisabledComponents编辑它的值,把值改成 0x20(就是十进制的32)。

image.png

4、重启计算机,然后打开命令行输入npm install lodashlodash安装成功

image.png