问题
I have submodules that install the same npm packages. Their node modules install same npm packages as other node modules in the repo. How can i consolidate all of the npm packages into one package.json file so that there are no duplicate packages installed?
回答1:
@slebetman is correct. Libraries may share dependencies, but they will likely use different versions of each. Also, shameless plug to a very similar question I answered a while back where someone was essentially asking "Why not install dependencies globally so we don't have to reinstall over and over what we already have?"
Answered here.
回答2:
Had a nasty bug with NPM duplicating nested modules. Switching to Yarn helped.
So try yarn install
instead of npm install
.
来源:https://stackoverflow.com/questions/38734039/handling-duplicate-npm-packages