问题
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:
- My project depend on PackageA and PackageB
- PackageA also depend on PackageB
- Both My project and PackageA depend on the same verison of PackageB
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?
回答1:
It was a bug, fixed in NPM 3.4.1:
https://github.com/npm/npm/issues/10446
来源:https://stackoverflow.com/questions/33750940/npm-dependencies-shared-by-dependencies