Angular 8: ng build production stuck at 11% and system hangs not able to create production build

1.2k views Asked by At

I am using Angular 8 and trying to create production build.

Here is the configuration

Angular CLI: 8.1.3
Node: 12.14.1
OS: linux x64
Angular: 8.1.3
... animations, cli, common, core, forms, language-service
... platform-browser, platform-browser-dynamic, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.803.21
@angular-devkit/build-angular      0.803.21
@angular-devkit/build-optimizer    0.803.21
@angular-devkit/build-webpack      0.803.21
@angular-devkit/core               8.3.21
@angular-devkit/schematics         8.3.29
@angular/cdk                       8.2.3
@angular/compiler                  8.1.2
@angular/compiler-cli              8.1.2
@angular/flex-layout               8.0.0-beta.27
@angular/http                      5.2.11
@angular/material                  8.2.3
@angular/material-moment-adapter   11.2.13
@ngtools/webpack                   8.3.21
@schematics/angular                8.1.3
@schematics/update                 0.803.29
rxjs                               6.4.0
typescript                         3.4.3
webpack                            4.39.2

Here is the report that is generated.

{
  "header": {
    "reportVersion": 1,
    "event": "Allocation failed - JavaScript heap out of memory",
    "trigger": "FatalError",
    "filename": "report.20220504.181012.9143.0.001.json",
    "dumpEventTime": "2022-05-04T18:10:12Z",
    "dumpEventTimeStamp": "1651668012959",
    "processId": 9143,
    "cwd": "/home/reinforce/Documents/DMSbyHDA/LMS-BUILD",
    "commandLine": [
      "/usr/local/bin/node",
      "/home/reinforce/Documents/DMSbyHDA/LMS-BUILD/node_modules/jest-worker/build/workers/processChild.js"
    ],
    "nodejsVersion": "v12.14.1",
    "glibcVersionRuntime": "2.23",
    "glibcVersionCompiler": "2.17",
    "wordSize": 64,
    "arch": "x64",
    "platform": "linux",
    "componentVersions": {
      "node": "12.14.1",
      "v8": "7.7.299.13-node.16",
      "uv": "1.33.1",
      "zlib": "1.2.11",
      "brotli": "1.0.7",
      "ares": "1.15.0",
      "modules": "72",
      "nghttp2": "1.40.0",
      "napi": "5",
      "llhttp": "2.0.1",
      "http_parser": "2.8.0",
      "openssl": "1.1.1d",
      "cldr": "35.1",
      "icu": "64.2",
      "tz": "2019c",
      "unicode": "12.1"
    },
    "release": {
      "name": "node",
      "lts": "Erbium",
      "headersUrl": "https://nodejs.org/download/release/v12.14.1/node-v12.14.1-headers.tar.gz",
      "sourceUrl": "https://nodejs.org/download/release/v12.14.1/node-v12.14.1.tar.gz"
    },
    "osName": "Linux",
    "osRelease": "4.15.0-142-generic",
    "osVersion": "#146~16.04.1-Ubuntu SMP Tue Apr 13 09:27:15 UTC 2021",
    "osMachine": "x86_64",
    "cpus": [
      {
        "model": "Intel(R) Core(TM) i3-7020U CPU @ 2.30GHz",
        "speed": 2299,
        "user": 8252300,
        "nice": 1500,
        "sys": 1557100,
        "idle": 16613700,
        "irq": 0
      },
      {
        "model": "Intel(R) Core(TM) i3-7020U CPU @ 2.30GHz",
        "speed": 2300,
        "user": 8351100,
        "nice": 1100,
        "sys": 1548200,
        "idle": 17151200,
        "irq": 0
      },
      {
        "model": "Intel(R) Core(TM) i3-7020U CPU @ 2.30GHz",
        "speed": 2300,
        "user": 9043800,
        "nice": 5200,
        "sys": 1541000,
        "idle": 13187500,
        "irq": 0
      },
      {
        "model": "Intel(R) Core(TM) i3-7020U CPU @ 2.30GHz",
        "speed": 2300,
        "user": 8282500,
        "nice": 600,
        "sys": 1574500,
        "idle": 15440600,
        "irq": 0
      }
    ],
    "networkInterfaces": [
      {
        "name": "lo",
        "internal": true,
        "mac": "00:00:00:00:00:00",
        "address": "127.0.0.1",
        "netmask": "255.0.0.0",
        "family": "IPv4"
      },
      {
        "name": "enp2s0",
        "internal": false,
        "mac": "6c:2b:59:5e:57:3b",
        "address": "192.168.1.115",
        "netmask": "255.255.255.0",
        "family": "IPv4"
      },
      {
        "name": "wlp1s0",
        "internal": false,
        "mac": "fc:77:74:fc:6d:86",
        "address": "192.168.0.105",
        "netmask": "255.255.255.0",
        "family": "IPv4"
      },
      {
        "name": "lo",
        "internal": true,
        "mac": "00:00:00:00:00:00",
        "address": "::1",
        "netmask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
        "family": "IPv6",
        "scopeid": 0
      },
      {
        "name": "enp2s0",
        "internal": false,
        "mac": "6c:2b:59:5e:57:3b",
        "address": "fe80::fb9b:32bd:1aa8:c3f1",
        "netmask": "ffff:ffff:ffff:ffff::",
        "family": "IPv6",
        "scopeid": 2
      },
      {
        "name": "wlp1s0",
        "internal": false,
        "mac": "fc:77:74:fc:6d:86",
        "address": "fe80::f3aa:96e6:71c8:d36c",
        "netmask": "ffff:ffff:ffff:ffff::",
        "family": "IPv6",
        "scopeid": 3
      }
    ],
    "host": "reinforce-Vostro-15-3568"
  },
  "javascriptStack": {
    "message": "No stack.",
    "stack": [
      "Unavailable."
    ]
  },
  "nativeStack": [
    {
      "pc": "0x0000000000b05ba5",
      "symbol": "report::TriggerNodeReport(v8::Isolate*, node::Environment*, char const*, char const*, std::string const&, v8::Local<v8::String>) [/usr/local/bin/node]"
    },
    {
      "pc": "0x00000000009dbd93",
      "symbol": "node::OnFatalError(char const*, char const*) [/usr/local/bin/node]"
    },
    {
      "pc": "0x0000000000b3b18e",
      "symbol": "v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]"
    },
    {
      "pc": "0x0000000000b3b509",
      "symbol": "v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]"
    },
    {
      "pc": "0x0000000000ce68a5",
      "symbol": " [/usr/local/bin/node]"
    },
    {
      "pc": "0x0000000000ce6f36",
      "symbol": "v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]"
    },
    {
      "pc": "0x0000000000cf2dca",
      "symbol": "v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]"
    },
    {
      "pc": "0x0000000000cf3cd5",
      "symbol": "v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]"
    },
    {
      "pc": "0x0000000000cf66e8",
      "symbol": "v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [/usr/local/bin/node]"
    },
    {
      "pc": "0x0000000000cbd017",
      "symbol": "v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType) [/usr/local/bin/node]"
    },
    {
      "pc": "0x0000000000ff307b",
      "symbol": "v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]"
    },
    {
      "pc": "0x0000000001376259",
      "symbol": " [/usr/local/bin/node]"
    }
  ],
  "javascriptHeap": {
    "totalMemory": 2152759296,
    "totalCommittedMemory": 2148978464,
    "usedMemory": 2136008152,
    "availableMemory": 49490392,
    "memoryLimit": 2197815296,
    "heapSpaces": {
      "read_only_space": {
        "memorySize": 262144,
        "committedMemory": 32568,
        "capacity": 261872,
        "used": 32296,
        "available": 229576
      },
      "new_space": {
        "memorySize": 4194304,
        "committedMemory": 1101048,
        "capacity": 2094976,
        "used": 93696,
        "available": 2001280
      },
      "old_space": {
        "memorySize": 2035134464,
        "committedMemory": 2035068512,
        "capacity": 2023751328,
        "used": 2023642768,
        "available": 108560
      },
      "code_space": {
        "memorySize": 1474560,
        "committedMemory": 1344288,
        "capacity": 1286336,
        "used": 1286336,
        "available": 0
      },
      "map_space": {
        "memorySize": 1576960,
        "committedMemory": 1315184,
        "capacity": 987280,
        "used": 987280,
        "available": 0
      },
      "large_object_space": {
        "memorySize": 110067712,
        "committedMemory": 110067712,
        "capacity": 109962224,
        "used": 109962224,
        "available": 0
      },
      "code_large_object_space": {
        "memorySize": 49152,
        "committedMemory": 49152,
        "capacity": 3552,
        "used": 3552,
        "available": 0
      },
      "new_large_object_space": {
        "memorySize": 0,
        "committedMemory": 0,
        "capacity": 2094976,
        "used": 0,
        "available": 2094976
      }
    }
  },
  "resourceUsage": {
    "userCpuSeconds": 213.908,
    "kernelCpuSeconds": 4.08716,
    "cpuConsumptionPercent": 114.133,
    "maxRss": 2253484032,
    "pageFaults": {
      "IORequired": 154,
      "IONotRequired": 1040280
    },
    "fsActivity": {
      "reads": 46368,
      "writes": 0
    }
  },
  "uvthreadResourceUsage": {
    "userCpuSeconds": 92.9095,
    "kernelCpuSeconds": 2.39474,
    "cpuConsumptionPercent": 49.8975,
    "fsActivity": {
      "reads": 45240,
      "writes": 0
    }
  },
  "libuv": [
  ],
  "environmentVariables": {
    "NVM_RC_VERSION": "",
    "XDG_VTNR": "7",
    "XDG_SESSION_ID": "c2",
    "TERM_PROGRAM": "vscode",
    "XDG_GREETER_DATA_DIR": "/var/lib/lightdm-data/reinforce",
    "CLUTTER_IM_MODULE": "xim",
    "GIO_LAUNCHED_DESKTOP_FILE_PID": "2862",
    "SESSION": "ubuntu",
    "NVM_CD_FLAGS": "",
    "GPG_AGENT_INFO": "/home/reinforce/.gnupg/S.gpg-agent:0:1",
    "TERM": "xterm-256color",
    "XDG_MENU_PREFIX": "gnome-",
    "SHELL": "/bin/bash",
    "QT_LINUX_ACCESSIBILITY_ALWAYS_ON": "1",
    "TERM_PROGRAM_VERSION": "1.65.0",
    "ORIGINAL_XDG_CURRENT_DESKTOP": "Unity",
    "UPSTART_SESSION": "unix:abstract=/com/ubuntu/upstart-session/1000/1647",
    "GTK_MODULES": "gail:atk-bridge:unity-gtk-module",
    "NVM_DIR": "/home/reinforce/.nvm",
    "USER": "reinforce",
    "LS_COLORS": "rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:",
    "QT_ACCESSIBILITY": "1",
    "UNITY_HAS_3D_SUPPORT": "true",
    "XDG_SESSION_PATH": "/org/freedesktop/DisplayManager/Session0",
    "XDG_SEAT_PATH": "/org/freedesktop/DisplayManager/Seat0",
    "SSH_AUTH_SOCK": "/run/user/1000/keyring/ssh",
    "SESSION_MANAGER": "local/reinforce-Vostro-15-3568:@/tmp/.ICE-unix/2120,unix/reinforce-Vostro-15-3568:/tmp/.ICE-unix/2120",
    "DEFAULTS_PATH": "/usr/share/gconf/ubuntu.default.path",
    "GIO_LAUNCHED_DESKTOP_FILE": "/usr/share/applications/code.desktop",
    "UNITY_DEFAULT_PROFILE": "unity",
    "XDG_CONFIG_DIRS": "/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg",
    "DESKTOP_SESSION": "ubuntu",
    "PATH": "/home/reinforce/bin:/home/reinforce/.local/bin:/home/reinforce/bin:/home/reinforce/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",
    "QT_QPA_PLATFORMTHEME": "appmenu-qt5",
    "QT_IM_MODULE": "ibus",
    "JOB": "unity-settings-daemon",
    "XDG_SESSION_TYPE": "x11",
    "PWD": "/home/reinforce/Documents/DMSbyHDA/LMS-BUILD",
    "XMODIFIERS": "@im=ibus",
    "LANG": "en_GB.UTF-8",
    "GDK_BACKEND": "x11",
    "GDM_LANG": "en_US",
    "MANDATORY_PATH": "/usr/share/gconf/ubuntu.mandatory.path",
    "VSCODE_GIT_ASKPASS_EXTRA_ARGS": "--ms-enable-electron-run-as-node",
    "CHROME_DESKTOP": "code-url-handler.desktop",
    "COMPIZ_CONFIG_PROFILE": "ubuntu",
    "IM_CONFIG_PHASE": "1",
    "GDMSESSION": "ubuntu",
    "GTK2_MODULES": "overlay-scrollbar",
    "SESSIONTYPE": "gnome-session",
    "HOME": "/home/reinforce",
    "XDG_SEAT": "seat0",
    "SHLVL": "2",
    "VSCODE_GIT_ASKPASS_MAIN": "/usr/share/code/resources/app/extensions/git/dist/askpass-main.js",
    "LANGUAGE": "en_IN:en",
    "GNOME_DESKTOP_SESSION_ID": "this-is-deprecated",
    "UPSTART_EVENTS": "xsession started",
    "LOGNAME": "reinforce",
    "XDG_SESSION_DESKTOP": "ubuntu",
    "COMPIZ_BIN_PATH": "/usr/bin/",
    "VSCODE_GIT_IPC_HANDLE": "/run/user/1000/vscode-git-bc266c3d6c.sock",
    "DBUS_SESSION_BUS_ADDRESS": "unix:abstract=/tmp/dbus-2bEz5WzNEa",
    "XDG_DATA_DIRS": "/usr/share/ubuntu:/usr/share/gnome:/usr/local/share:/usr/share:/var/lib/snapd/desktop:/var/lib/snapd/desktop",
    "QT4_IM_MODULE": "xim",
    "LESSOPEN": "| /usr/bin/lesspipe %s",
    "VSCODE_GIT_ASKPASS_NODE": "/usr/share/code/code",
    "GIT_ASKPASS": "/usr/share/code/resources/app/extensions/git/dist/askpass.sh",
    "UPSTART_JOB": "unity7",
    "DISPLAY": ":0",
    "XDG_RUNTIME_DIR": "/run/user/1000",
    "XDG_CURRENT_DESKTOP": "Unity",
    "GTK_IM_MODULE": "ibus",
    "LESSCLOSE": "/usr/bin/lesspipe %s %s",
    "COLORTERM": "truecolor",
    "XAUTHORITY": "/home/reinforce/.Xauthority",
    "_": "/usr/local/bin/ng",
    "BROWSERSLIST_IGNORE_OLD_DATA": "1",
    "WEBPACK_DEV_SERVER": "true",
    "JEST_WORKER_ID": "2",
    "FORCE_COLOR": "1"
  },
  "userLimits": {
    "core_file_size_blocks": {
      "soft": 0,
      "hard": "unlimited"
    },
    "data_seg_size_kbytes": {
      "soft": "unlimited",
      "hard": "unlimited"
    },
    "file_size_blocks": {
      "soft": "unlimited",
      "hard": "unlimited"
    },
    "max_locked_memory_bytes": {
      "soft": 65536,
      "hard": 65536
    },
    "max_memory_size_kbytes": {
      "soft": "unlimited",
      "hard": "unlimited"
    },
    "open_files": {
      "soft": 1048576,
      "hard": 1048576
    },
    "stack_size_bytes": {
      "soft": 8388608,
      "hard": "unlimited"
    },
    "cpu_time_seconds": {
      "soft": "unlimited",
      "hard": "unlimited"
    },
    "max_user_processes": {
      "soft": 30692,
      "hard": 30692
    },
    "virtual_memory_kbytes": {
      "soft": "unlimited",
      "hard": "unlimited"
    }
  },
  "sharedObjects": [
    "/lib/x86_64-linux-gnu/libdl.so.2",
    "/usr/lib/x86_64-linux-gnu/libstdc++.so.6",
    "/lib/x86_64-linux-gnu/libm.so.6",
    "/lib/x86_64-linux-gnu/libgcc_s.so.1",
    "/lib/x86_64-linux-gnu/libpthread.so.0",
    "/lib/x86_64-linux-gnu/libc.so.6",
    "/lib64/ld-linux-x86-64.so.2"
  ]
}

here is angular.json

{
  "name": "test",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "build-prod": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --prod"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "^1.1.0",
    "@amcharts/amcharts4": "^4.10.24",
    "@angular/animations": "~8.1.2",
    "@angular/cdk": "^8.0.0",
    "@angular/common": "~8.1.2",
    "@angular/compiler": "~8.1.2",
    "@angular/core": "~8.1.2",
    "@angular/flex-layout": "^8.0.0-beta.27",
    "@angular/forms": "~8.1.2",
    "@angular/material": "^8.2.3",
    "@angular/material-moment-adapter": "^11.2.12",
    "@angular/platform-browser": "~8.1.2",
    "@angular/platform-browser-dynamic": "~8.1.2",
    "@angular/router": "~8.1.2",
    "@kolkov/angular-editor": "^1.0.2",
    "@swimlane/ngx-datatable": "^16.0.2",
    "@types/google-maps": "^3.2.2",
    "angular-clock": "^0.7.0",
    "angular-datatables": "^8.0.0",
    "bootstrap": "^4.4.1",
    "bootstrap-multiselect": "^0.9.15",
    "datatables.net": "^1.10.20",
    "datatables.net-dt": "^1.10.20",
    "emma": "0.0.1",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "html-to-pdfmake": "^2.0.8",
    "html2canvas": "^1.0.0-rc.5",
    "jquery": "^3.4.1",
    "jquery-ui": "^1.12.1",
    "jspdf": "^1.5.3",
    "jspdf-autotable": "^3.5.6",
    "moment": "^2.29.1",
    "ng2-ckeditor": "^1.2.6",
    "ng6-toastr-notifications": "^1.0.4",
    "ngx-doc-viewer": "^0.1.20",
    "ngx-document-view": "^1.0.1",
    "ngx-spinner": "^8.1.0",
    "pdfmake": "^0.1.65",
    "rxjs": "~6.4.0",
    "sass": "^1.42.1",
    "tslib": "^1.9.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.803.21",
    "@angular/cli": "~8.1.2",
    "@angular/compiler-cli": "~8.1.2",
    "@angular/language-service": "~8.1.2",
    "@schematics/angular": "~8.1.2",
    "@types/datatables.net": "^1.10.18",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/jquery": "^3.3.31",
    "@types/node": "~8.9.4",
    "codelyzer": "^5.2.1",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "node-sass": "^4.14.1",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.4.3"
  },
  "description": "This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.1.2.",
  "main": "karma.conf.js",
  "author": "",
  "license": "ISC"
}

I have used node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --prod but problem is not solved.

What is the issue? I had Used lazy loading for modules. Is there a version issue or something else.

Do i have to update my angular.json file?

The build takes hours and system gets hangs

Also getting these error while running ng build

[error] Error: Call retries were exceeded
    at ChildProcessWorker.initialize (/**/node_modules/jest-worker/build/workers/ChildProcessWorker.js:193:21)
    at ChildProcessWorker.onExit (/**/node_modules/jest-worker/build/workers/ChildProcessWorker.js:263:12)
    at ChildProcess.emit (events.js:311:20)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)

0

There are 0 answers