1
votes

Not sure why this is happening... been Googling but I can't seem to find an answer. I have 2 macs, on each of them I have a folder containing the same package.json file, which contains a list of 20 dependencies. When I run "npm install" on...

Computer 1: installs all the listed dependencies within their own folders - 20 folders total.

Computer 2: installs a ton of different folders - 561 to be exact. These extra folders appear to be dependencies of the main dependencies that I have listed in package.json.

Just curious why this is happening, and if there is anyway to control how npm downloads and groups dependencies? I appreciate the smaller overall file size of the computer downloading 561 folders... but there may be instances where I require the organization of the grouped dependencies.

Thanks!

1

1 Answers

3
votes

The newest version of NPM does a "flatter" install with dependencies not nested as deep as the earlier version. It sounds like if you compare NPM versions, you will find you have different versions on the two computers.

Here's an article about the older way:

npm is installing dependencies in a weird recursive way

And, change log info about the new way:

https://github.com/npm/npm/blob/master/CHANGELOG.md#flat-flat-flat

One of the main advantages of this is the sharing (rather than duplicating) of module dependencies used by more that one parent module. In the new flat scheme, there is only one copy of the module that is used in more than one place rather than many copies.