我无法为我的react应用程序安装模块,当我运行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:UsersmarcoCodebackendnode_modules.stagingsetprototypeof-b857a2acpackage.json'
npm WARN tar ENOENT: no such file or directory, open 'C:UsersmarcoCodebackendnode_modules.stagingsetprototypeof-b857a2acindex.d.ts'
npm WARN tar ENOENT: no such file or directory, open 'C:UsersmarcoCodebackendnode_modules.stagingsetprototypeof-b857a2acindex.js'
npm WARN tar ENOENT: no such file or directory, open 'C:UsersmarcoCodebackendnode_modules.stagingsetprototypeof-b857a2acLICENSE'
npm WARN tar ENOENT: no such file or directory, open 'C:UsersmarcoCodebackendnode_modules.stagingrc-5aecd98btestini.js'
npm WARN tar ENOENT: no such file or directory, open 'C:UsersmarcoCodebackendnode_modules.stagingsetprototypeof-b857a2acREADME.md'
npm WARN tar ENOENT: no such file or directory, open 'C:UsersmarcoCodebackendnode_modules.stagingrc-5aecd98btestnested-env-vars.js'
npm WARN tar ENOENT: no such file or directory, open 'C:UsersmarcoCodebackendnode_modules.stagingrc-5aecd98btesttest.js'
npm WARN tar ENOENT: no such file or directory, open 'C:UsersmarcoCodebackendnode_modules.stagingterm-size-f230f088vendorwindowsterm-size.exe'
npm WARN tar ENOENT: no such file or directory, open 'C:UsersmarcoCodebackendnode_modules.stagingast-types-5383d6ccdeftype-annotations.js'
npm WARN tar ENOENT: no such file or directory, open 'C:UsersmarcoCodebackendnode_modules.stagingast-types-5383d6ccdeftypescript.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:wsdepsopensslopensslsslrecordssl3_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
。有什么帮助吗?附言:我没有使用代理
快速解决方案是删除node_modules
和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使用特定的格式?