Irina
Irina

Reputation: 276

Why npm installs so much modules with this package.json?

I have recently updated npm to version 3.3.3, and started a new project after that. My package.json is as follows:

{
  "name": "my project",
  "description": "my description",
  "version": "1.0.0",
  "license": "MIT",
  "devDependencies": {
    "gulp": "^3.8.11",
    "gulp-uglify": "^1.4.1",
    "gulp-watch": "^4.1.1",
    "gulp-rename": "^1.2.2",
    "gulp-concat": "^2.5.2",
    "gulp-autoprefixer": "^2.1.0",
    "gulp-sass": "^1.3.3",
    "browser-sync": "^2.7.13"
  }
}

After doing npm install I see 352 installed modules in node_modules directory. Before updating npm, I had only 10-15 installed modules using very similar package.json (with a few additional dependencies) for another project.

So thee question is, why the new version of npm installs so much modules, and can I somehow change its behavior?

Upvotes: 1

Views: 239

Answers (1)

eush77
eush77

Reputation: 4088

This is one of the core features of npm@3: all dependencies of your dependencies are now installed in the same top-levelnode_modules directory, when possible.

From the changelog:

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.

This will hopefully eliminate most cases where windows users ended up with paths that were too long for Explorer and other standard tools to deal with.

There is no way to disable that.

Upvotes: 4

Related Questions