简体   繁体   English

如何使用 loadVirtual 和 ENOLOCK 修复 npm 审计错误?

[英]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 running these:尝试运行这些:

npm i --package-lock-only
npm config get package-lock
npm config get shrinkwrap
npm i --package-lock-only
npm audit fix

From here .这里

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.

相关问题 ENOLOCK npm 错误! 运行 npm 审计修复时出错 - ENOLOCK npm ERR! Error while running npm audit fix npm 审计修复 --force 和 - npm 审计修复之间的区别? - Difference between npm audit fix --force and - npm audit fix? 使用 npm 安装 live-server 包时出错。 `npm audit` 无助于解决问题 - Getting error while installing live-server package using npm. `npm audit` is not helping to fix the problem 如何解决 NPM 审计漏洞? - How to resolve NPM audit vulnerabilities? 在显示“发现 1 个低严重性漏洞运行 `npm audit fix` 来修复它们,或 `npm audit` 以获取详细信息”后反应应用程序创建将停止 - react app creation going to stop after showing "found 1 low severity vulnerability run `npm audit fix` to fix them, or `npm audit` for details" 多个 npm 审计修复后无法运行 Vue 应用程序 - Cannot run Vue app after multiple npm audit fix 如何修复审计灯塔建议以提高绩效 - How to fix audit lighthouse suggestions for Improved performance 如何修复错误“npm ERR!缺少脚本:开始” - How to fix error "npm ERR! missing script: start" 如何使用 npm 链接修复 Angular 库中的“未找到模块”错误? - How to fix "Module not found" error in Angular library with npm link? 我该如何修复Windows 10中的npm build错误? - How do i fix npm build error in windows 10?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM