npm 错误!代码 ERR_SOCKET_TIMEOUT npm 错误!网络套接字超时

Ira*_*Ira 22 node.js npm-install

这是错误:

npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! network Socket timeout
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'
Run Code Online (Sandbox Code Playgroud)

我跑了npm cache clean --force

删除node_modulespackage-lock.json运行npm install但仍然出现该错误

mod*_*7ex 26

试试这个答案

或运行npm i -g npm@8.5.1

我认为这是 npm 版本的问题,8.5.1 在大多数情况下解决了问题

基本上尝试早期版本,我认为问题会得到解决


Sup*_*ita 25

几天前我遇到了这个错误。我更改了超时,它对我有用。(注意:我的 npm 版本是8.19.1

您也可以在其他 npm 版本中尝试此解决方案。

首先,检查当前设置。为了检查当前设置运行npm config ls -l

然后,检查这 4 个值(fetch-retries、fetch-retry-factor、fetch-retry-maxtimeout、fetch-retry-mintimeout、fetch-timeout)

$ npm config ls -l

fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
fetch-timeout = 300000
Run Code Online (Sandbox Code Playgroud)

要更改超时,请运行这两个命令 -

npm config set fetch-retry-mintimeout 20000

npm config set fetch-retry-maxtimeout 120000

  • 这对我有用 npm 9.x (2认同)

cpt*_*lly 7

我不确定这是否对其他人有帮助,但对我来说似乎有效的是断开我公司的 VPN 连接并重新建立它!