[英]how to fix npm audit error with loadVirtual and ENOLOCK?
➜ npm audit
npm ERR! code ENOLOCK
npm ERR! audit This command requires an existing lockfile.
npm ERR! audit Try creating one first with: npm i --package-lock-only
npm ERR! audit Original error: loadVirtual requires existing shrinkwrap file
I ran npm audit and got this error.我运行了 npm 审计并得到了这个错误。
When I run below:当我在下面运行时:
➜ npm config get package-lock
true
➜ npm config get shrinkwrap
true
Can anybody help with this?有人可以帮忙吗? as to how to fix it?
至于如何解决? and npm audit fix --force is not working as well...
和 npm 审计修复 --force 不能正常工作......
I just ran the command it says to.我刚刚运行了它所说的命令。
npm i --package-lock-only
Then it showed me 0 vulnerabilities.然后它向我展示了 0 个漏洞。 Anyway, ran again
audit fix and again 0 vulnerabilities.
无论如何,再次运行审核修复并再次运行 0 个漏洞。
works for me like this:像这样为我工作:
npm cache clean --force
npm fund
npm audit fix --force
That error tells you the root of the problem: This command requires an existing lockfile.
该错误告诉您问题的根源:
This command requires an existing lockfile.
. . This implies that you don't already have a
package-lock.json
along side the package.json
you're trying to audit.这意味着您在尝试审核的
package.json
旁边还没有package-lock.json
。 npm i --package-lock-only
just generates/updates package-lock.json without reinstalling; npm i --package-lock-only
只生成/更新 package-lock.json 无需重新安装; npm i
would reinstall and generate one (based on your config). npm i
将重新安装并生成一个(基于您的配置)。
You need to create package-lock.json, run您需要创建 package-lock.json,运行
npm install
then然后
npm audit fix
you won't have the problem你不会有问题
I updated to the latest version of npm with npm install -g npm@8.3.0
, and now it shows no more problems...我用
npm install -g npm@8.3.0
更新到最新版本的 npm ,现在它显示没有更多问题了......
Try these command.
试试这些命令。
npm i --package-lock-only
npm config get package-lock
npm config get shrinkwrap
npm i --package-lock-only
npm audit fix
Use Node 14, it fixed the issue with 0 vulnerabilities.使用 Node 14,它修复了 0 个漏洞的问题。
I read this and really helpful:我读了这个,真的很有帮助:
https://medium.com/illumination/how-to-fix-npm-audit-error-with-loadvirtual-and-enolock-deprecated-dependencies-1f07ba65eef9 https://medium.com/illumination/how-to-fix-npm-audit-error-with-loadvirtual-and-enolock-deprecated-dependencies-1f07ba65eef9
npm i --package-lock-only npm config get package-lock npm config get shrinkwrap npm i --package-lock-only npm audit fix npm i --package-lock-only npm config get package-lock npm config get shrinkwrap npm i --package-lock-only npm audit fix
(When running 'npm config get package-lock' and 'npm config get shrinkwrap', you will receive 'true' for both) — → After running 'npm audit fix', you will see: “up to date, audited… found 0 vulnerabilities” (当运行 'npm config get package-lock' 和 'npm config get shrinkwrap' 时,您将收到两者的 'true')— → 运行 'npm audit fix' 后,您将看到:“up to date, audited... found 0个漏洞”
The problem is because you need a package.json and package-lock.json file running these commands will fix it for you.问题是因为您需要一个 package.json 和 package-lock.json 文件运行这些命令将为您修复它。
npm init -y npm 初始化-y
npm i --package-lock-only npm i --package-lock-only
npm audit npm审核
This fixes the problem这解决了问题
Had the same error, then realized I was in a parent folder.有同样的错误,然后意识到我在父文件夹中。 So this may happen if there's no lock file.
因此,如果没有锁定文件,可能会发生这种情况。
Try running this command: npm cache clean --force尝试运行此命令:npm cache clean --force
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.