Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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...

like image 387
facVV Avatar asked Jan 05 '21 05:01

facVV


People also ask

How do I fix security vulnerability in npm?

If security vulnerabilities are found and updates are available, you can either: Run the npm audit fix subcommand to automatically install compatible updates to vulnerable dependencies. Run the recommended commands individually to install updates to vulnerable dependencies.


3 Answers

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.

like image 112
kleonardof Avatar answered Oct 17 '22 22:10

kleonardof


works for me like this:

npm cache clean --force

npm fund

npm audit fix --force
like image 30
Marcelo Carvalho Avatar answered Oct 17 '22 20:10

Marcelo Carvalho


The problem is that you need a package.json and package-lock.json file in the directory.

Running the following commands will fix it for you.

npm init -y

npm i --package-lock-only

npm audit

This fixes the problem

like image 9
Gorre Shashidhar Reddy Avatar answered Oct 17 '22 21:10

Gorre Shashidhar Reddy