Safeguard
Developer Tools•

Why does an npm SBOM list the same package twice?

npm can install one package in several places, and the CycloneDX npm tool does not merge them. How to read repeated entries and when flattening helps.

Safeguard Security Team
4 min read

Because the package really is installed more than once. When two dependencies need different versions, or npm cannot hoist a copy, the same name appears at several places in the tree. The CycloneDX npm tool does not merge them, so each installed copy becomes its own component.

What the tool says

The README states that the tool does not do artificial deduplication, so if a component is installed multiple times, it appears multiple times in the SBOM result. A linked document explains the reasoning: npm already performs the needed graph deduplication internally when it builds the on disk layout, and extra logic would either be invalid or unnecessary.

In other words, the repeats are not noise added by the generator. They reflect npm's actual layout.

Two kinds of repeat

Look at the entries before deciding anything.

PatternWhat it meansAction
Same name, different versionsTwo dependents need different rangesReal. Check whether both are patched
Same name and version, different pathsOne version installed in two placesUsually harmless, but both copies ship
Same name and version, same pathLikely a generator or merge artifactInvestigate

The first row deserves the most attention. A vulnerability fix applied to one copy does nothing for the other, and a scan that only looks at the highest version will miss it.

How to read the list

  1. Sort components by name.
  2. For each name with several entries, compare versions and paths. Component properties in the file, where present, can show where each copy lives, for example the package path that npm's own sbom output records.
  3. For differing versions, trace which dependent pulls each one in, using the dependency graph in the file.
  4. For identical entries in different paths, confirm both are needed at runtime.

The dependency graph is the useful part. It tells you which parent asked for which copy, so you know what to upgrade to remove the old one.

Can you remove the repeats?

The tool has a flatten components option that removes the nesting representation. The README describes it as meaning the actual nesting of node packages is not represented in the result. Flattening changes how components are arranged, not which packages exist, and you lose the structure that tells you where each copy lives. Use it only if a consumer cannot handle nested components, and keep an unflattened copy for your own analysis.

On the npm side, the dedupe command can reduce duplicate installs by reshaping the tree where version ranges allow. That changes your install, so it is a dependency management decision to test, not an SBOM setting.

What not to do

Do not delete duplicates by hand from a published SBOM. The file is supposed to describe the build, and hand edits break that. If the count looks wrong, fix the cause or regenerate.

Do not count components and call the number a risk figure. A repeated package inflates the count without adding a new library.

Using the result

When matching vulnerabilities, make sure your tool evaluates each installed version separately. Safeguard's SBOM and dependency scanning reads each component with its version and path, and reachability analysis shows which of the vulnerable copies your code calls. A free scan will show it for your project.

Quick check

Is a repeated component a bug in the SBOM?

Usually not. It reflects how npm installed the packages. Check versions and paths to see whether it matters.

Does flattening reduce my risk?

No. It changes how the file is arranged, and it loses the structure showing where each copy sits.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.