node.js - npm 审核失败,套接字挂起 (ECONNRESET) (WSL)
问题描述
关于如何让“npm audit”在适用于 Linux 的 Windows 子系统 (WSL) 中工作的任何想法?运行命令“npm audit”会导致错误消息“失败,原因:socker hang up”。
从 Windows 10 WSL2 下的全新 Ubuntu 18.04 LTS 安装开始,我可以使用以下命令登录并重现错误:
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | 重击
- 重击
- nvm安装--lts
- npx express-generator HelloWorld --view=pug
- cd HelloWorld
- npm 安装
- npm 审计
结果错误:
npm 错误!代码 ECONNRESET npm 错误!errno ECONNRESET npm 错误!对https://registry.npmjs.org/-/npm/v1/security/audits的网络请求失败,原因:套接字挂起
我为解决问题所做的事情:
- 我使用 curl 和 wget 从错误中指定的 npmjs 注册表 URL 获得有效响应
- 'npm audit' 在带有 Node JS v14.15.1 的 Windows 10 下工作
- 在 WSL2 下使用 Debian 也会出现该错误
- 使用不同版本(nvm 版本 0.37.2、节点 v14.15.1、节点 v15.3.0、npm v6.14.8 和 npm v7.0.14)会发生错误
- 无论 Windows 防火墙是打开还是关闭,都会发生错误
- 清除 npm 缓存并没有改变任何东西
- npm 未配置为使用代理服务器
- 对 npm 注册表 url 使用 HTTP 而不是 HTTPS 并不能解决问题
有关进一步的故障排除步骤或可能的修复的任何想法?到目前为止,我已经用谷歌搜索并尝试了所有可能的解决方案,但没有运气。
先感谢您!
解决方案
In case this helps someone else... WSL2 has a minimum build requirement of Windows 10 version 1909 (build 10.0.18363), but the command "npm audit" did not work on this version. Upgrading Windows 10 to version 2004 resolved the problem.
推荐阅读
- python - KeyError:使用本机 python 时为 12
- python - 使用熊猫的两个时间戳之间的差异每天剩余小时
- java - Hibernate:如何级联未映射的实体?
- c# - 取消订阅其他活动中的活动
- python - 如何绘制与 plt.contourf 的决策边界相同的决策边界线?
- google-sheets - 列出或自动完成现有字符串值,用于新的纯文本单元格
- java - 在centos中,当Tomcat 7关闭时,就发生了这很可能造成内存泄漏。不知道为什么
- react-native - Metro bundler 将生成的 Bundle 存储在哪里?
- c# - 使用服务参考的肥皂请求
- node.js - 选择一个文件,然后使用 Nodemailer 将其作为附件发送!节点