npm dedupe
can flatten the folder structure. However, before doing that. I hope to see a list of duplicate packages, so that I know whether or not to go forward. Is there such a feature? If not, is there some sort of scripts that help me achieve this?
deduped is short for "deduplicated" (duplicates were removed). The documentation for npm dedupe explains how npm does this: Searches the local package tree and attempts to simplify the overall structure by moving dependencies further up the tree, where they can be more effectively shared by multiple dependent packages.
Description. This command removes "extraneous" packages. If a package name is provided, then only packages matching one of the supplied names are removed. Extraneous packages are those present in the node_modules folder that are not listed as any package's dependency list.
With npm or yarn, you can install a package under a custom alias. This enables you to install multiple versions of a package in the same project. Read the documentation on aliasing with npm here and yarn here.
To check for all globally installed packages and its dependencies, run the npm list command followed by the -g flag. This above command prints the all globally installed packages in tree view.
Try this:
npm ls --parseable | xargs -L1 sh -c 'basename $1' dummy | sort | uniq -c | grep -v "^ *1 " | sort -rn
The pipeline here is:
Try find-duplicate-dependencies. As well as versions it shows you the simplified path to the duplicates:
$ find-duplicate-dependencies
This package has the following duplicate dependencies:
regenerator-runtime :
[ { name: 'regenerator-runtime',
version: '0.11.1',
from: undefined,
path: 'project/react-select/emotion/babel-plugin-emotion/babel-core/babel-runtime' },
{ name: 'regenerator-runtime',
version: '0.12.1',
from: undefined,
path: 'project/recompose/@babel/runtime' } ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With