npm err!代码err_socket_timeout npm err!网络套接字超时
这个错误:
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'
我ran npm缓存清洁 - force
删除 node_modules
and package> package> package-lock.json
and code> npm npm install ,但仍然让我这个错误
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(15)
尝试此答案< /a>
或运行
npm i -g
我认为这是NPM版本的问题,8.5.1在大多数情况下解决了问题,
基本上是尝试较早版本,我认为问题将被解决
Try this answer
or run
npm i -g [email protected]
i think it's an issue with npm version , 8.5.1 solves the problem in most cases
basically try earlier versions and i think the problem will be solved
几天前,我面对这个错误。我改变了超时,对我有用。 (注意:我的NPM版本是 8.19.1 )
您也可以使用其他NPM版本尝试此解决方案。
首先,检查当前设置。要检查当前设置运行
npm config ls -l </code>
,然后检查以下4个值(fetch-retries,fetch-retry-factor,fetch-retry-maxtimeout,fetch-retry-mintimeout,fetch time out )
要更改时间,请运行这两个命令
-
npm配置设置fetch-retry-mintimeout 20000
npm config设置fetch-retry-maxtimeout 120000
I faced this error some days ago. I changed the timeout and it works for me. (Note: my npm version was 8.19.1)
You can try this solution with other npm versions as well.
First of all, check the current settings. For checking the current settings run
npm config ls -l
Then, check these 4 values (fetch-retries, fetch-retry-factor, fetch-retry-maxtimeout, fetch-retry-mintimeout, fetch-timeout)
For changing the time out, Run these two commands-
npm config set fetch-retry-mintimeout 20000
npm config set fetch-retry-maxtimeout 120000
我不确定这是否会对其他任何人有所帮助,但是似乎对我有用的是放弃公司的VPN连接并重新建立它!
I am not sure if this will help anyone else, but what appears to have worked for me was dropping my company's VPN connection and reestablishing it!
我通过在
.npmrc
文件中为NPM设置60000个超时,解决了此问题。要从终端执行此操作,只需执行以下操作:$ NANO .NPMRC
如果您需要本地配置,请从您的工作目录中进行。添加
timeout = 60000
,保存,您就可以了。最初在此处发布: https://github.com/github.com/facebook/createbook/create-react--react--react--react--react--react--react--react--react--react--- App/esseage/10251
I solved this by setting a timeout of 60000 for npm in the
.npmrc
file. To do that from your terminal, simply do the following:$ nano .npmrc
from your work directory if you want a configuration locally.Add
timeout=60000
, save and you're good to go.Originally posted here: https://github.com/facebook/create-react-app/issues/10251
尝试通过运行以下命令来删除代理设置:
Try removing proxy settings by running the commands below:
我最近遇到了这个问题。我尝试了许多解决方案,例如
npm缓存验证
,npm缓存清洁 - force
,npm config set fetch-retry-retry-mintimeout
,npm config set fetch-retry-maxtimeout
,使用npm和/或节点的不同版本删除package-lock.json。但是对我有用的解决方案是切换到纱线。
I faced this problem recently. I tried many solutions like
npm cache verify
,npm cache clean --force
,npm config set fetch-retry-mintimeout
,npm config set fetch-retry-maxtimeout
, deleting package-lock.json, using different version of npm and/or node.But the solution that worked for me was to switch to yarn.
您可以使用纱线软件包管理器解决此问题。
纱线创建React-App My-App
希望它有帮助。
You can resolve this using YARN package manager.
yarn create react-app my-app
hope it help.
在我的情况下,它是yarn.lock文件可用性。因此,由于响应时间延迟,安装程序试图获取依赖项并丢弃错误。因此,将npm设置为
In my scenario, it was the yarn.lock file availability. So the installer tried to fetch dependencies and threw an error since the response time was delayed. So deleted both yarn.lock and package.lock file and reinstalled after setting npm to [email protected]
我能够改用
纱线安装
安装软件包。I was able to install packages using
yarn install
instead.我找到了解决方案,这对我有用
1.NPM配置设置注册表 2.npm i或npm i -save-leggacy-peer-deps
I found solution for it, which works great for me
1.npm config set registry http://registry.npmjs.org/
2.npm i or npm i --save --legacy-peer-deps
我的问题是我的系统使用了Homebrew版本的NPM,而不是使用TJ/N安装的系统。一旦我运行
Brew卸载节点
一切都很好。My problem was that my system was using the homebrew version of npm, not the one I installed with tj/n. Once I ran
brew uninstall node
everything was fine again.就我而言,删除
Yarn.lock
文件解决了问题。In my case, deleting the
yarn.lock
file solved the problem.我有这个问题。事实证明,我有两个VPN打开。一旦我关闭了不适合该项目的VPN,它就可以了。可能值得检查是否需要VPN来运行项目,或者是否需要在运行项目之前关闭VPN。
I had this problem. It turned out that I have two VPNs turned on. Once I turned off the VPN that was not meant for this project, it worked. It might worth checking if you need a VPN to run your project or if you need to turn the VPN off before running the project.
降级
节点
从20到19帮助我(MacOS,Homebrew):Downgrading
node
from 20 to 19 helped me (macOS, homebrew):我的使用这些步骤工作,希望它也适合您。
然后,
如果不是这样,那么您的Internet连接可能很差或有代理设置错误。让我知道它是否不起作用。
mine worked using these steps, hope it works for you too.
and then
if it does not then probably your internet connection is poor or there is a proxy set up error. let me know if it does not work.