npm prune
all
Remove extraneous packages from `node_modules`. Note: Extraneous packages are those present in the node_modules folder that are not listed as any package's dependency list.
More info →Examples (5)
Remove all extraneous packages not listed in dependencies
Remove extraneous packages and devDependencies (useful for production builds)
npm prune --productionShow what would be removed without making any changes
npm prune --dry-runOutput the changes as JSON
npm prune --jsonRemove specific packages by name
npm prune package_namemade by @shridhargupta | data from tldr-pages