npm install 报错 The package-lock.json file was created with an old version of npm, npm WARN o

1.问题背景

解决方法直接看3
博主在VScode中用 npm install 命令下载包时报错,错误如下

npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.       
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile

changed 1 package, and audited 2 packages in 6s

found 0 vulnerabilities

2.报错原因

npm版本过高,解决方法见第如下,亲测有效可以解决。

3.解决方法

1.在vscode终端中输入如下命令行(可直接复制粘贴)

npm i npm@6 -g

2.然后输入

npm -v

检查npm版本会显示一个低版本的 npm 的版本号。
在这里插入图片描述
3.然后再进行npm install 的操作就不会报错了。

参考博客地址:

https://docker.blog.csdn.net/article/details/120564807?spm=1001.2014.3001.5506

补充遇到的其他问题

  1. 显示 found 0 vulnerabilities 代表这个包已经安装过了,不用再安装,包可以在当前目录中的 node_modues 目录中找到。

猜你喜欢

转载自blog.csdn.net/dxy1128/article/details/126024025