简体   繁体   中英

An unhandled exception occurred: Call retries were exceeded on build prod with angular 9

I am having error while building my project for production. Also it is taking too much time while generating the es5 bundles.

Generating ES5 bundles for differential loading...
An unhandled exception occurred: Call retries were exceeded

Here is my versions:

"@angular-extensions/elements": "^9.1.3",
"@angular/animations": "^9.1.1",
"@angular/cdk": "^9.2.0",
"@angular/common": "^9.1.1",
"@angular/compiler": "^9.1.1",
"@angular/core": "^9.1.1",
"@angular/elements": "^9.1.1",
"@angular/flex-layout": "^9.0.0-beta.29",
"@angular/forms": "^9.1.1",
"@angular/localize": "^9.1.1",
"@angular/material": "^9.2.0",
"@angular/platform-browser": "^9.1.1",
"@angular/platform-browser-dynamic": "^9.1.1",
"@angular/router": "^9.1.1",

"@angular-devkit/build-angular": "^0.901.1",
"@angular-devkit/build-ng-packagr": "~0.901.1",
"@angular-devkit/core": "^9.1.1",
"@angular/cli": "~9.1.1",
"@angular/compiler-cli": "^9.1.1",

For anyone else with this issue, I found it's because Node's default memory limits are somewhat low. Or atleast too low for many mid-size Angular projects.

You are able to edit this globally for NodeJS, but then that means it will still break on another developers machine, or in your build pipeline.

So the best option I found was to edit my package.json and add a custom script like so:

"scripts": {
  "build-prod": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng build --prod",
}

And then when I need to build, instead of calling ng build --prod, I just call NPM run build-prod which does basically the same thing, but increases the memory limit (With the added bonus that if I want additional flags for my production build I can add them here to).

Taken from here: https://tutorialsforangular.com/2020/08/29/fixing-angular-build-memory-issues/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM