Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node js adding unwanted modules when I do npm install [duplicate]

I am trying to spin up a node service on my mac. When I run npm install in the folder where my node service is, it is installing modules which are not mentioned in my package.json. There are extra modules which I am not expecting and some modules that I expect are missing. What could be the reason? How does the node modules folder get created. Does it use any global set up? I am a newbie to nodejs and any help will be appreciated.

like image 623
User1234321232 Avatar asked May 29 '26 08:05

User1234321232


2 Answers

Well, it has been introduced with npm3 (https://github.com/npm/npm/blob/master/CHANGELOG.md#v300-2015-06-25):

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.

like image 191
Fer To Avatar answered May 30 '26 21:05

Fer To


I believe this is something new that happened in the newest version of npm.

If I'm not mistaken, it's installing all the dependencies flat instead of nested inside of whichever module that needs it.

like image 37
Mark Pieszak - Trilon.io Avatar answered May 30 '26 21:05

Mark Pieszak - Trilon.io



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!