I'm trying to remove unused packages from the package.json files for a few projects but I'm running into issues with peer dependencies. There are some tools, such as depcheck
, which try to list all of the "unused" packages, but it doesn't differentiate between actual unused packages, and packages that are unused because they're peer dependencies.
Is there a package out there, or some npm
command I'm not familiar with, that will allow me to either list all peer dependencies in my project or, at the very least, allow me to type in a package name and see if that package is installed because it's a peer dependency of another package?
For posterity, here's an example of just the dependencies for one of my projects. In this project, I know for instance that reflect-metadata
is a peer dependency of @nestjs/common
, but I only discovered that after uninstalling it.
"dependencies": {
"@google-cloud/storage": "^3.2.1",
"@google-cloud/vision": "^1.3.0",
"@google/maps": "^0.5.5",
"@nestjs/common": "^6.6.7",
"@nestjs/core": "^6.6.7",
"@nestjs/platform-express": "^6.6.7",
"@slack/webhook": "^5.0.1",
"@typeform/api-client": "^1.5.1",
"algoliasearch": "^3.34.0",
"array-uniq": "^2.1.0",
"basic-auth": "^2.0.1",
"child-process-promise": "^2.2.1",
"class-transformer": "^0.2.3",
"class-validator": "^0.10.0",
"express": "^4.17.1",
"firebase-admin": "^8.5.0",
"firebase-functions": "^3.2.0",
"geoip-lite": "^1.3.8",
"geolib": "^3.0.4",
"glob": "^7.1.4",
"hbs": "^4.0.4",
"hubspot-api": "^2.2.10",
"json2csv": "^4.5.3",
"lodash": "^4.17.15",
"luxon": "^1.17.2",
"node-fetch": "^2.6.0",
"postmark": "^2.2.9",
"promise-settle": "^0.3.0",
"qrcode": "^1.4.1",
"redux": "^4.0.4",
"reflect-metadata": "^0.1.13",
"rxjs": "^6.5.3",
"sales-tax": "^2.0.10",
"sanitize-filename": "^1.6.3",
"sharp": "^0.23.0",
"stripe": "^7.9.0"
},