How to find duplicate npm packages?

npm dedupe can flatten the folder structure. However, before doing this. I hope to see a list of duplicate packages so that I know whether to go or not. Is there such a feature? If not, are there any scenarios that help me achieve this?

+7
javascript npm
source share
1 answer

Try the following:

  npm ls --parseable | xargs -L1 sh -c 'basename $1' dummy | sort | uniq -c | grep -v "^ *1 " | sort -rn 

Conveyor:

  • List of packages in the allowed format
  • Separate each path to the package name
  • Sort package names in alphabetical order to prepare for unique name counting
  • Group and count unique package names
  • Hide packages that are not duplicated (count = 1)
  • Sort again in decreasing number of occurrences
+11
source share

All Articles