NPM dependencies shared by dependencies

On npm 3.3.12 (node 4.2.2), the following thing happen:

I run npm install in a project where one of the dependencies in my project is also a dependency of one of the other dependencies. For instance:

    <li>My project depend on PackageA and PackageB</li> <li>PackageA also depend on PackageB</li> <li>Both My project and PackageA depend on the same verison of PackageB</li> </ul>

    Then, I run npm update in my prroject. The NPM output lists:

    PackageB@x.x.x node_modules/PackageB -> node_modules/PackageA/node_modules/PackageB

    So then suddenly PackageB is not in node_modules of my project (only in node_modules under PackageA) and require("PackageB") in the files of the project fails.

    What is causing this, and how can I best avoid the issue?


    It was a bug, fixed in NPM 3.4.1: