node.js - npm 安装不工作:“npm ERR!代码 ERR_SSL_WRONG_VERSION_NUMBER”
问题描述
我无法为我的反应应用程序安装模块,当我运行npm i
它时:
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\setprototypeof-b857a2ac\package.json'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\setprototypeof-b857a2ac\index.d.ts'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\setprototypeof-b857a2ac\index.js'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\setprototypeof-b857a2ac\LICENSE'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\rc-5aecd98b\test\ini.js'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\setprototypeof-b857a2ac\README.md'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\rc-5aecd98b\test\nested-env-vars.js'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\rc-5aecd98b\test\test.js'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\term-size-f230f088\vendor\windows\term-size.exe'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\ast-types-5383d6cc\def\type-annotations.js'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\ast-types-5383d6cc\def\typescript.js'
npm WARN backend@1.0.0 No description
npm WARN backend@1.0.0 No repository field.
npm ERR! code ERR_SSL_WRONG_VERSION_NUMBER
npm ERR! errno ERR_SSL_WRONG_VERSION_NUMBER
npm ERR! request to https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz failed, reason: 4376:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:308:
npm ERR!
我尝试重新安装 npm,它做同样的事情。我尝试了另一个项目,但遇到了同样的错误。我发现了另一个问题,有人有同样的问题,但没有人回答。我什至尝试将 npm 注册表设置为,http://registry.npmjs.org
而不是https://registry.npmjs.org
将strict-ssl
选项设置为 false,但它仍然无法正常工作。我的 npm 版本是6.14.13
,我的节点版本是v14.17.1
. 有什么帮助吗?PS:我没有使用代理
解决方案
快速的解决方案是删除node_modules
and package-lock.json
,这样当您重新安装软件包时,它们会被安装lockfileVersion@1
而不是lockfileVersion@2
.
不过,我不会建议该解决方案,就好像您在一个团队中工作一样,您会迫使其他人也这样做以修复它。
问题是 npm 版本v6.x.x
支持lockfileVersion@1
而v7.x.x
支持lockfileVersion@2
.
因此,更好的解决方案是将您的 npm 版本简单地更新到 v7 或更高版本。
在这里你可以找到一个有趣的相关讨论:有什么方法可以修复 package-lock.json lockfileVersion 以便 npm 使用特定格式?
推荐阅读
- android - 将属性传递给正在使用它的视图中的可绘制对象
- html - 悬停时更改字段的背景(HTML,CSS)
- ios - Firebase Analytics 事件不显示 ad_click 和 ad_impression 事件
- reactjs - 如何使用 react-google-maps 禁用街景?
- javascript - 反应图像未在多站点页面上加载
- asp.net-mvc - MVC 中的 .NET Highcharts
- swift - 解析日期需要大量 RAM
- java - 如何将 SQL 结果集输出限制为 1 个结果而不是每个查询的结果?
- python - 为什么设置一个变量等于另一个变量会改变这段代码中的任何内容?
- docker - 使用 Docker 和 Hyper-V 重定向端口