JavaScript heap out of memory

Sooner or actually later, when your Angular app is getting bigger in size, you could get the error JavaScript heap out of memory when trying to serve/build your project.

Update the “scripts” in your package.json file to:

  "scripts": {
    "ng-high-memory-serve": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng serve --port",
    "ng-high-memory-build": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng build",
    "ng-high-memory-build-prod": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng build --prod",
    "ng": "ng",
    "start": "npm run ng-high-memory-serve",
    "build": "npm run ng-high-memory-build --extract-css",
    "build:ssr": "npm run build -- --app=ssr --output-hashing=media",
    "build:prod": "npm run ng-high-memory-build-prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"

In the console use, start or build, … to get things running.