javascript - npm 将所有依赖项和子依赖项放在同一个文件夹中

标签 javascript linux node.js npm

我的项目中有一个包含大约 20 个依赖项的 package.json 文件。当我做的时候

npm install

它将所有依赖项和子依赖项放在最顶层的 node_modules 目录中。它包含数百个模块,而它应该只有我的 20 个。子依赖项应该在我的主要依赖项下的 node_module 目录中,但它创建了一个平面结构。

我在 Ubuntu 14.04 上使用 npm 3.5.4 和 Node 0.10.41

任何人都可以帮助我安装具有正确树结构的模块吗?

编辑----- 添加我的 packages.json 文件:

    {
  "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"
    }
  }
}

最佳答案

这是预期的行为。由于版本 3 npm 尝试删除重复的依赖项并尽可能使用平面树。

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

关于javascript - npm 将所有依赖项和子依赖项放在同一个文件夹中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34572863/

相关文章:

javascript - 新点击时显示/隐藏重置

android - 在 Linux 虚拟机中配置 Android Studio 和 SDK 时出错

c - 原始类型定义的 GCC 编译器错误

javascript - 在 Javascript 中将立体声音频转换为单声道

javascript - 监控对象属性的变化

php - javascript : unexpected non-whitespace character after JSON data 中的 JSON 错误

javascript - 缓存异步函数的结果,并将其传递给 Async.js 中的下一个函数

node.js - 使用 base64 图像数据在 NodeJS 中进行图像处理

javascript - 使用 cron 调度任务后,如果服务器崩溃会发生什么

linux - SSH端口转发