当我npm install
从package.json
文件使用base时,它安装了337个库:/这是我的包文件
{ "name": "system_glowna", "version": "2.0.0", "dependencies": { "angular2": "^2.0.0-beta.0", "bootstrap": "^3.3.6", "es6-promise": "^3.0.2", "es6-shim": "^0.33.3", "reflect-metadata": "0.1.2", "rxjs": "5.0.0-beta.0", "systemjs": "0.19.6", "zone.js": "0.5.10" }, "devDependencies": { "del": "^1.2.0", "gulp": "^3.8.11", "gulp-autoprefixer": "^2.2.0", "gulp-concat": "^2.5.2", "gulp-inject": "^1.2.0", "gulp-less": "^3.0.3", "gulp-load-plugins": "^0.10.0", "gulp-minify-css": "^1.1.6", "gulp-minify-html": "^1.0.3", "gulp-rename": "^1.2.2", "gulp-replace": "^0.5.3", "gulp-uglify": "^1.2.0", "gulp-watch": "^4.2.4", "run-sequence": "^1.1.0" } }
为什么要安装这么多的库?如何限制它们?
版本3.x之前的npm在树结构中安装库,因此每个库都有自己的node_modules,依此类推.它可能导致(或几乎总是引导)不同node_modules包中的重复库,并导致相当大的node_modules文件夹.事情变得棘手,例如在Windows上,路径可能太长而无法在之后轻松删除node_modules.
但是,在3.x发布npm之后,它默认使用平面文件夹结构,并且只有在存在任何冲突时才会为每个库安装正确的版本.
请注意自己 - 为了让每个库正常工作,npm安装了如此多的库这一事实:)