Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.7k views
in Technique[技术] by (71.8m points)

angular - ng build --prod have javaScript heap out of memory error

I am facing the below issue while using ng build --prod.

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

Tried increasing the size limit by using https://github.com/endel/increase-memory-limit but it is still failing to build. Do i need to change anywhere in the node_modules?

10% building modules 6/8 modules 2 active ...ootstrapdistcssootstrap 90% chunk assets processing<--- Last few GCs --->

174152 ms: Mark-sweep 1266.2 (1435.6) -> 1265.2 (1435.6) MB, 934.7 / 0.0 ms [allocation failure] [GC in old space requested]. 175021 ms: Mark-sweep 1265.2 (1435.6) -> 1265.2 (1435.6) MB, 869.8 / 0.0 ms [allocation failure] [GC in old space requested]. 175964 ms: Mark-sweep 1265.2 (1435.6) -> 1267.9 (1410.6) MB, 942.4 / 0.0 ms [last resort gc]. 176889 ms: Mark-sweep 1267.9 (1410.6) -> 1271.4 (1410.6) MB, 924.1 / 0.0 ms [last resort gc].

<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0000011C7D03FA99 1: getLast(aka getLast) [E:projectsNila Companymemaranefront-end ode_modulesescopelibpattern-visitor.js:~45] [pc=000002C336273AA1] (this=0000011C7D004241 ,xs=0000037217E78589 ,xs=0000037217E78589 ) 2: Identifier [E:projectsNila Companymemaranefront-end ode_modulesescopelibpattern-visitor.js:76] [pc=000002C335B8874A] (this=0000037217E78539

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

and my dependencies are :

  "dependencies": {
    "@angular/animations": "^4.0.0",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "@mm2/bsmodal": "^1.0.1",
    "@ng-bootstrap/ng-bootstrap": "1.0.0-beta.5",
    "@ngu/carousel": "^1.4.2",
    "angular-froala-wysiwyg": "^1.0.0",
    "angular-popper": "^1.0.0-beta-1",
    "angular2-jwt": "^0.2.3",
    "animate.css": "^3.5.2",
    "aos": "^2.2.0",
    "bootstrap": "4.0.0-beta.2",
    "core-js": "^2.4.1",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "jalali-moment": "^2.1.8",
    "jquery": "^3.2.1",
    "ng2-completer": "^1.6.1",
    "ng2-datepicker-jalali": "^1.0.9",
    "ng2-scroll-to-el": "^1.0.0",
    "ngx-carousel": "^1.3.1",
    "ngx-cookie-service": "^1.0.9",
    "ngx-progressbar": "^2.1.1",
    "ngx-quill": "^1.6.0",
    "ngx-quill-editor": "^2.2.2",
    "popper.js": "^1.12.9",
    "rxjs": "^5.4.1",
    "wowjs": "^1.1.3",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "^1.6.1",
    "@angular/compiler-cli": "^4.0.0",
    "@angular/language-service": "^4.0.0",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/jquery": "^3.2.16",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.0.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.0.4",
    "tslint": "~5.3.2",
    "typescript": "~2.3.3"
  }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I was facing same issue with ionic 3 unit testing.

npm test

was getting memory issue in above command then got it fixed with below commands--

npm install

node --max_old_space_size=8048 ./node_modules/@angular/cli/bin/ng test

It worked for me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...