What is deduped in npm packages list?

2020-05-24 19:02发布

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

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

标签: node.js npm
1条回答
Animai°情兽
2楼-- · 2020-05-24 19:22

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 content-type@1.0.4 is a dependency of body-parser. A bit further down, it's also listed as a direct dependency of express one level higher.

查看更多
登录 后发表回答