Skip to content

Instantly share code, notes, and snippets.

@ashx3s
Last active November 18, 2021 05:52
Show Gist options
  • Select an option

  • Save ashx3s/52a4356d5cb7eee315d71493c693b59b to your computer and use it in GitHub Desktop.

Select an option

Save ashx3s/52a4356d5cb7eee315d71493c693b59b to your computer and use it in GitHub Desktop.
Fix NPM Vulnerabilities

Fix NPM Vulnerabilities

Fixing npm security vulnerabilities can be daunting but isn't too difficult. These steps should get you through most fixes. This process will work for both npm and yarn setups (just change the commands).

  1. Perform an audit to figure out what packages are causing the vulnerabilities
npm audit
  • The audit will show the affected packages.
  1. Add the packages and versions to the package.json. Make sure to use the right version numbers
{
  "resolutions": {
    "package-name": "^3.2.1",
    "other-package": "^1.2.3"
  }
}
  1. Then add this to the package.json.
{
  "scripts": {
    "preinstall": "npx npm-force-resolutions"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment