You might previously use commands like npm audit
or yarn audit
to perform a vulnerability audit against the installed packages. In case any vulnerable dependencies found to update it you could use built-in npm audit fix
command. It would automatically install any compatible updates to vulnerable dependencies. Surprisingly, there is no yarn
alternative to fix it in the way npm
does, yet there are several workarounds which you can do.
The very straight forward option is to use yarn-audit-fix
package.
1yarn add yarn-audit-fix -D
Alternatively, you can use npx
.
1npx yarn-audit-fix
1yarn-audit-fix
This is my preferable approach to fix vulnerable dependencies.
package-lock.json
file without installing node modules1npm install --package-lock-only
package-lock.json
file1npm audit fix
yarn.lock
file and import the package-lock.json
file into yarn.lock
1rm yarn.lock2
3yarn import
package-lock.json
file1rm package-lock.json
Sign up to get updates when I write something new. No spam ever.
Subscribe to my Newsletter