handle npm vulnerabilities

Publish : Update :

카테고리:

태그: ,

Handling npm vulnerabilities

If not solved after npm audit fix or npm audit fix --force

Method 1 - Reinstall

  • remove package-lock.json and reinstall
    rm -rf node_modules package-lock.json && npm install
    

Method 2 - Clean Cache

  • command related in clean cache(no explanation)
    npm list # just check installed package list
    npm cache clean
    npm cache clean --force
    npm cache verify
    npm i --pakcage-lock-only
    

Method 3 - Resolution

  • Install minimist
    npm install minimist --save-dev
    
  • Add resolution in package.json
    "resolutions": {
     "minimist": "^1.2.5"
    }
    
  • Add preinstall script
    "scripts": {
      "preinstall": "npx npm-force-resolutions"
    }
    
  • execute npm install
  • execute npm ls minimist check
    • if not resolved, reinstall compatible version of packages occuring vulnerabilities

    it could be solved but depend on which package installed for using