0

Im using Angular and ngx-bootstrap yet I have 269 folders within node_modules. Surely not all of these are necessary? Is there a way to determine if some of those 269 folders are no longer needed ? The node_modules folder is over 88MB! I might have installed a few other packages in the last few days but I cant remember since I also had to manually adjust my package.json file.

Here is my package.json

{
  "author": "me",
  "dependencies": {
    "@angular/cdk": "^2.0.0-beta.8",
    "@angular/common": "~4.3.0",
    "@angular/compiler": "~4.3.0",
    "@angular/core": "~4.3.0",
    "@angular/forms": "~4.3.0",
    "@angular/http": "~4.3.0",
    "@angular/platform-browser": "~4.3.0",
    "@angular/platform-browser-dynamic": "~4.3.0",
    "@angular/router": "~4.3.0",
    "angular-in-memory-web-api": "~0.2.4",
    "core-js": "^2.5.0",
    "moment": "^2.18.1",
    "moment-timezone-all": "^0.5.5",
    "rxjs": "5.0.1",
    "systemjs": "0.19.40",
    "zone.js": "^0.8.4"
  },
  "description": "A starter app using Angular2, Bootstrap CSS for hosting within an ASP.NET MVC web app",
  "devDependencies": {
    "@types/node": "^6.0.85",
    "alertify.js": "^1.0.12",
    "bootstrap": "^3.3.7",
    "font-awesome": "^4.7.0",
    "jquery": "^3.2.1",
    "modernizr": "^3.5.0",
    "ngx-bootstrap": "^1.8.1",
    "systemjs": "^0.19.40"
  },
  "keywords": [],
  "license": "MIT",
  "name": "aspng2",
  "repository": {},
  "version": "1.0.0"
}
bitshift
  • 6,026
  • 11
  • 44
  • 108
  • 1
    You can try `npm prune` (see https://stackoverflow.com/questions/21417014/npm-command-to-uninstall-unused-packages-in-node-js), but the reality is that frameworks like Angular are enormous and the JavaScript ecosystem is huge now, so it's quite possible you won't be able to save any space at all. – Jim Stewart Aug 11 '17 at 16:25
  • ^ This should be the answer. `npm prune`. '269' doesn't look too odd because NPM 3 and higher have plain directory structure. And 88MB is considered small for Angular project. – Estus Flask Aug 11 '17 at 23:04

1 Answers1

1

If you use the Angular CLI and use its ng build --prod, it will perform some level of "tree shaking" for you. That means that it will remove unused pieces of these vendor features so that the packages you deploy are significantly smaller.

See the docs here for more information: https://angular.io/guide/aot-compiler#tree-shaking

DeborahK
  • 57,520
  • 12
  • 104
  • 129