Introduction
Managing packages with npm (a.k.a. nod package manager) recently experienced some major changes.
While npm version 2 stored dependent packages in a deeply nested folder tree, version 3 will flatten the dependency folder structure as much as possible.
In general, I am a great fan of this new behavior. For some special cases there may be a reason to stick with the older structure, at least for some time. E.g. for some existing packages may still rely on the nested structure.
Using the code
A rather straight froward approach is already implemented in npm@3, but it is well hidden somewhere in the backrooms of documentation [^]. A google search today brought up some unconventional and impractical ideas. So I wanted to share this hint with you:
Using the --legacy-bundling
flag will install packages in the well-known deeply nested structure.
npm install --legacy-bundling
This stops any flattening or deduping functionality.
If you happen to have trouble with legacy packages, probalby this can help you. If not, just please ignore this tip and enjoy the flattened, deduped node modules structure ;)
History
Keep a running update of any changes or improvements you've made here.