angular-cli: Build fails with JavaScript heap out of memory
Bug Report or Feature Request (mark with an x
)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Command (mark with an x
)
- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Versions
npm 6.4.1 yarn 1.9.4 Angular CLI: 7.0.1 Node: 8.12.0 OS: darwin x64 Angular: 7.0.0 … animations, cdk, common, compiler, compiler-cli, core, forms … http, language-service, material, material-moment-adapter … platform-browser, platform-browser-dynamic, platform-server … router, service-worker
Package Version
@angular-devkit/architect 0.10.1 @angular-devkit/build-angular 0.10.1 @angular-devkit/build-optimizer 0.10.1 @angular-devkit/build-webpack 0.10.1 @angular-devkit/core 7.0.1 @angular-devkit/schematics 7.0.1 @angular/cli 7.0.1 @angular/pwa 0.10.1 @ngtools/webpack 7.0.1 @schematics/angular 7.0.1 @schematics/update 0.10.1 rxjs 6.3.3 typescript 3.1.3 webpack 4.19.1
Repro steps
run ng build client --prod
The log given by the failure
92% chunk asset optimization TerserPlugin
<--- Last few GCs --->
[6911:0x102801e00] 224585 ms: Mark-sweep 1318.9 (1444.5) -> 1318.9 (1444.5) MB, 1195.0 / 0.0 ms allocation failure GC in old space requested
[6911:0x102801e00] 225921 ms: Mark-sweep 1318.9 (1444.5) -> 1318.9 (1429.5) MB, 1336.0 / 0.0 ms last resort GC in old space requested
[6911:0x102801e00] 227268 ms: Mark-sweep 1318.9 (1429.5) -> 1318.9 (1429.5) MB, 1347.5 / 0.0 ms last resort GC in old space requested
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x130c21da5879 <JSObject>
1: /* anonymous */ [/node_modules/source-map/lib/source-node.js:~342] [pc=0xa501c16fd08](this=0x130cfc80c2f1 <JSGlobal Object>,chunk=0x130c584834b1 <String[1]: .>,original=0x130cc679e159 <Object map = 0x130cb6748611>)
2: SourceNode_walk [/node_modules/source-map/lib/source-node.js:~221] [pc=0xa501c57db1e](t...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [/usr/local/bin/node]
2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
4: v8::internal::Factory::NewUninitializedFixedArray(int) [/usr/local/bin/node]
5: v8::internal::(anonymous namespace)::ElementsAccessorBase<v8::internal::(anonymous namespace)::FastPackedObjectElementsAccessor, v8::internal::(anonymous namespace)::ElementsKindTraits<(v8::internal::ElementsKind)2> >::GrowCapacity(v8::internal::Handle<v8::internal::JSObject>, unsigned int) [/usr/local/bin/node]
6: v8::internal::Runtime_GrowArrayElements(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
7: 0xa501a5042fd
error Command failed with signal "SIGABRT".
Desired functionality
v6 doesn’t have any issue building the same app.
Mention any other details that might be useful
I can’t shared any code as it’s a big client project, and I suspect it the size that’s causing the issue as basic apps build ok.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 10
- Comments: 23 (2 by maintainers)
allows build to complete, just need to know why my bundle has increase by 260kb
increase maximum memory allocated in angular.json “budgets”: [ { “type”: “initial”, “maximumWarning”: “2mb”, “maximumError”: “11mb” } ]
My team was facing the same issue and this is how we resolved.
While building a project just use this command instead of
ng build client --prod
node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --prod --build-optimizer
Why is this issue closed?
Just upgraded to node
v12.10.0
and it didn’t go away for us, unfortunately.I am facing a similar issue on our app as well.
Angular 8.1.2
try to modify the files and replace their contents with the following: (in the folder : node_modules\bin)
Modify ng.cmd:
Modify ngc.cmd :
Here too. Working with Docker with 2GB RAM. It worked fine with node 10, but reaches the memory limit with node 12.