➜ 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...
works for me like this:
npm cache clean --force
npm fund
npm audit fix --force
You need to create package-lock.json, run
npm install
then
npm audit fix
you won't have the problem
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”
I updated to the latest version of npm with npm install -g npm@8.3.0, and now it shows no more problems...
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
Try running this command: npm cache clean --force
Had the same error, then realized I was in a parent folder. So this may happen if there's no lock file.
I just ran the command it says to.
npm i --package-lock-only
Then it showed me 0 vulnerabilities. Anyway, ran again audit fix and again 0 vulnerabilities.
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).