I'm getting unexpected behavior when using npm. For example when installing express with the command:
npm install express
I would expect that a folder named, "express" would be created in the "node_modules" directory and that it's dependencies would be installed within a "node_modules" sub-directory within this folder.
What I am seeing is that the "express" folder is being created but all of it's dependencies are being added to the root "node_modules" directory (same level as express) in my project folder and not nested within the "express" folder.
Why is this happening? (using npm v3.3.5)
It's a design change for npm@3, it deduplicates by default. See:
Flat, flat, flat!
Your dependencies will now be installed maximally flat. Insofar as is possible, all of your dependencies, and their dependencies, and THEIR dependencies will be installed in your project's
node_modules
folder with no nesting. You'll only see modules nested underneath one another when two (or more) modules have conflicting dependencies.
https://github.com/npm/npm/blob/ff47bc138e877835f1c0f419fea5f5672110678a/CHANGELOG.md#flat-flat-flat
https://github.com/npm/npm/issues/6912
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With