NPM now has npm ci (which I think should be the default) for that.
If so, ignore this, but if not, wouldn't adding a new package have all sorts of weird side effects from miscellaneous updates to irrelevant existing dependencies?
So it ends up with un-optimized structure sometimes. Because the top package is locked and does not meet the version new package required.
In order to satisfy the constraint. Npm will install second copy of the package in nested directory.
And npm also have a `dedup` command for you to `screw it, change the version in lock and merge them if possible`.
I think if you're careful about what you pull in from npm it's totally fine.
I also dont like that some packages are too big, or too small, or have too many transitive dependencies. It is a fact of life in npm land, though, making deterministic builds simultaneously minor and significant.