What is deduped in npm packages list?

node.jsNpm

node.js Problem Overview


I am running command as npm list and I get below mentioned list as my dependencies and I want to know what is the meaning of deduped. Please let me know the meaning of this.

Please check below mention image...!!!!

node.js Solutions


Solution 1 - node.js

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.

In other words, it looks if multiple packages have the same dependencies (meaning the same packages and version range) and "points" them to the same package.

The same package is referenced, so it doesn't have to be installed twice.

Also, it moves the packages "up the tree" (flattens the tree). This makes total sense as otherwise one package would have to look in the node_modules of some other package (which would be kind of messy) and helps to simplify the dependencies.

You can validate this, as every package in your dependency graph that says deduped, can be found at least one more time in the graph, usually at a higher level.

In the screenshot you posted [email protected] is a dependency of body-parser. A bit further down, it's also listed as a direct dependency of express one level higher.

Solution 2 - node.js

Sadly i can only post it here and not in the comment section, since i don't have 50 rep, but with npm v8.3 you can also use overrides for packages in your tree:

https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides

Why do i mention it?

-> overrides are also tagged with "deduped" no mater how high they are on tree, so even if package x in branch y is only listened once it still will be marked "deduped"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionYash ChoksiView Question on Stackoverflow
Solution 1 - node.jsZaphoidView Answer on Stackoverflow
Solution 2 - node.jsSilver SkyView Answer on Stackoverflow