Ad

Npm Is Putting All Dependencies And Sub-dependecies Int He Same Folder

- 1 answer

I have a package.json file with about 20 dependencies in my project. When I do

npm install

it places all the dependencies and sub-dependencies in the top most node_modules directory. It contains hundreds of modules when it should only be my 20. The sub-dependencies should be in the node_module directories under my main dependencies but it has created a flat structure.

I'm using npm 3.5.4 and node 0.10.41 on Ubuntu 14.04

Can any one assist me in getting the modules to install like they should with the correct tree structure?

EDIT----- Adding my packages.json file:

    {
  "name": "lms",
  "version": "1.0.0",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "license": "ISC",
  "dependencies": {
    "aliasify": "^1.8.0",
    "angular": "^1.4.7",
    "angular-animate": "^1.4.7",
    "angular-aria": "^1.4.7",
    "angular-material": "^0.11.4",
    "angular-resource": "^1.4.7",
    "angular-ui-router": "^0.2.15",
    "angular-ui-sortable": "^0.13.4",
    "backbone": "^1.2.3",
    "bootstrap": "^3.3.5",
    "browser-sync": "^2.9.12",
    "browserify": "^12.0.1",
    "browserify-ngannotate": "^1.0.1",
    "del": "^2.1.0",
    "eslint": "^1.8.0",
    "eslint-config-defaults": "^7.1.1",
    "font-awesome": "^4.5.0",
    "gulp": "^3.9.0",
    "gulp-clean": "^0.3.1",
    "gulp-concat": "^2.6.0",
    "gulp-connect": "^2.2.0",
    "gulp-connect-php": "0.0.7",
    "gulp-eslint": "^1.1.1",
    "gulp-minify-css": "^1.2.1",
    "gulp-ng-annotate": "^1.1.0",
    "gulp-open": "^1.0.0",
    "gulp-sass": "^2.1.0",
    "gulp-uglify": "^1.4.2",
    "jquery": "^2.1.4",
    "jquery-ui": "^1.10.5",
    "lodash": "^3.10.1",
    "merge-stream": "^1.0.0",
    "ng-backbone": "file:local_node_modules/ng-backbone",
    "vinyl-buffer": "^1.0.0",
    "vinyl-source-stream": "^1.1.0"
  },
  "browserify": {
    "transform": [
      "aliasify"
    ]
  },
  "aliasify": {
    "aliases": {
      "underscore": "lodash"
    }
  }
}
Ad

Answer

This is intended behaviour. Since version 3 npm tries to de-duplicate dependencies and use a flat tree whereever possible.

See https://docs.npmjs.com/how-npm-works/npm3

Ad
source: stackoverflow.com
Ad