JavaScript heap out of memory Angular Heroku

  angular, heroku, out-of-memory

I have an Angular front end application that I am trying to deploy to Heroku. Everything works fine locally but I am getting a JavaScript heap out of memory error when trying to deploy.

I have found other questions like this that recommend:

"start": "node --max_old_space_size=2560 node_modules/.bin/react-scripts start",

but I am not using react.

I have also seen:

node --max-old-space-size=4096 yourFile.js

but I am not using node and I’m not sure which file I should put for "yourFile.js"


  "name": "howling-wolfe",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "heroku-postbuild": "ng build --prod && npm install -g http-server-spa",
    "start": "node --max-old-space-size=4096 main.js",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "postinstall": "ngcc"
  "private": true,
  "dependencies": {
    "@angular-devkit/build-angular": "~0.1100.2",
    "@angular/animations": "~11.0.1",
    "@angular/cdk": "^11.2.6",
    "@angular/cli": "~11.0.2",
    "@angular/common": "~11.0.1",
    "@angular/compiler": "~11.0.1",
    "@angular/compiler-cli": "~11.0.1",
    "@angular/core": "~11.0.1",
    "@angular/flex-layout": "^11.0.0-beta.33",
    "@angular/forms": "~11.0.1",
    "@angular/material": "^11.2.6",
    "@angular/platform-browser": "~11.0.1",
    "@angular/platform-browser-dynamic": "~11.0.1",
    "@angular/router": "~11.0.1",
    "angular-in-memory-web-api": "^0.11.0",
    "rxjs": "~6.6.0",
    "tslib": "^2.0.0",
    "typescript": "~4.0.2",
    "uuid": "^3.4.0",
    "zone.js": "~0.10.2"
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1100.2",
    "@angular/cli": "~11.0.2",
    "@angular/compiler-cli": "~11.0.1",
    "@types/jasmine": "~3.6.0",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.1.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~4.0.2"

Not sure what else is relevant but can post more code snippets if requested…

Does anyone know an Angular specific solution to this problem?

Thanks in advance!

Source: Angular Questions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.