➜ 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.
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...
I just ran the command it says to.
npm i --package-lock-only
Then it showed me 0 vulnerabilities. Anyway, ran again 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 implies that you don't already have a package-lock.json
along side the package.json
you're trying to audit. npm i --package-lock-only
just generates/updates package-lock.json without reinstalling; npm i
would reinstall and generate one (based on your config).
You need to create package-lock.json, run
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...
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.
I read this and really helpful:
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”
The problem is because you need a package.json and package-lock.json file running these commands will fix it for you.
npm init -y
npm i --package-lock-only
npm audit
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.