npm install加载不在package.js中的模块

时间:2016-06-16 15:06:48

标签: npm

我有一个看起来像这样的package.json文件。

    {
      "name": "package",
      "version": "1.0.0",
      "description": "wordpress",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "",
      "license": "ISC",
      "devDependencies": {
        "grunt": "^0.4.5",
        "grunt-cli": "^0.1.13",
        "grunt-contrib-cssmin": "^0.9.0",
        "load-grunt-tasks": "^0.4.0",
        "grunt-bower-install": "~0.7.0",
        "grunt-contrib-sass": "^0.7.3",
        "grunt-contrib-jshint": "^0.10.0",
        "grunt-contrib-uglify": "^0.4.0",
        "grunt-contrib-watch": "^0.6.1",
        "grunt-contrib-concat": "^0.4.0",
        "grunt-concat-css": "^0.3.1",
        "matchdep": "^0.3.0",
        "grunt-bower-install": "^1.6.0",
        "grunt-modernizr": "^0.5.2",
        "grunt-notify": "~0.2.3"
      }
    }

当我跑步时

npm install     

它创建了一个node_modules文件夹,在package.json文件中添加了模块,但还添加了许多我没有引用过的模块。

1 个答案:

答案 0 :(得分:0)

您看到的额外模块是您明确安装的模块的依赖关系 - 换句话说,它们是 package.json中列出的内容。例如,如果您安装async模块,则lodash也会安装,因为async依赖于它才能运行。