Angular 2 - 使用 AOT 构建:Javascript 堆内存不足
Angular 2 - Build with AOT : Javascript heap out of memory
我正在开发一个angular2项目。我 运行 下面的命令来构建 AOT 包。
ng build --aot --prod
但是 returns 错误:
68% building modules 1135/1172 modules 37 active ...cy/node_modules/rxjs/operator/last.js
<--- Last few GCs --->
[15184:0x2c46890] 91090 ms: Mark-sweep 1363.5 (1447.6) -> 1363.5 (1447.6) MB, 717.9 / 0.0 ms allocation failure GC in old space requested
[15184:0x2c46890] 91834 ms: Mark-sweep 1363.5 (1447.6) -> 1363.6 (1431.6) MB, 742.9 / 0.0 ms last resort GC in old space requested
[15184:0x2c46890] 92632 ms: Mark-sweep 1363.6 (1431.6) -> 1363.5 (1431.6) MB, 798.3 / 0.0 ms last resort GC in old space requested
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x378f8390427d]
Security context: 0x2cc5da1206a9 <JSObject>
1: symbolToParameterDeclaration(aka symbolToParameterDeclaration) [/home/mahmood/WebProjects/bisphone-beta-web-lucy/node_modules/typescript/lib/typescript.js:~26179] [pc=0x378f84af538f](this=0x344d038022e1 <undefined>,parameterSymbol=0x1445395f60c1 <SymbolObject map = 0x2b2a3dd2ab11>,context=0x3631eda341b1 <Object map = 0x2b2a3dd51b71>)
2: signatureT...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [ng]
2: 0x88050c [ng]
3: v8::Utils::ReportOOMFailure(char const*, bool) [ng]
4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [ng]
5: v8::internal::Factory::NewLoadHandler(int) [ng]
6: v8::internal::LoadHandler::LoadFromPrototype(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::Smi>, v8::internal::MaybeHandle<v8::internal::Object>, v8::internal::MaybeHandle<v8::internal::Object>) [ng]
7: v8::internal::LoadIC::ComputeHandler(v8::internal::LookupIterator*) [ng]
8: v8::internal::LoadIC::UpdateCaches(v8::internal::LookupIterator*) [ng]
9: v8::internal::LoadIC::Load(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Name>) [ng]
10: v8::internal::Runtime_LoadIC_Miss(int, v8::internal::Object**, v8::internal::Isolate*) [ng]
11: 0x378f8390427d
Aborted (core dumped)
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! bisphone-plus@0.0.0 build: `ng build --aot --prod`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the bisphone-plus@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
我搜索了解决方案,在 failed - JavaScript heap out of memory” and Angular 2 AOT build error - JavaScript heap out of memory 中发现了两个类似的问题。
在这些帖子之后,添加 add --max-old-space-size=9000
属性 但结果发生了变化:
69% building modules 1689/1690 modules 1 active .../@firebase/database/dist/index.cjs.js
#
# Fatal error in , line 0
# API fatal error handler returned after process out of memory
#
#
#
#FailureMessage Object: 0x7f6efe578980Illegal instruction (core dumped)
项目不是很大,前几天搭建成功。没有 --aot --prod
的 ng build
有效。
这对我有用
node --max_old_space_size=5120 ./node_modules/@angular/cli/bin/ng build --prod --build-optimizer
通过将打字稿形式 2.6.x 更新为 2.7.x 问题已解决。
我正在开发一个angular2项目。我 运行 下面的命令来构建 AOT 包。
ng build --aot --prod
但是 returns 错误:
68% building modules 1135/1172 modules 37 active ...cy/node_modules/rxjs/operator/last.js
<--- Last few GCs --->
[15184:0x2c46890] 91090 ms: Mark-sweep 1363.5 (1447.6) -> 1363.5 (1447.6) MB, 717.9 / 0.0 ms allocation failure GC in old space requested
[15184:0x2c46890] 91834 ms: Mark-sweep 1363.5 (1447.6) -> 1363.6 (1431.6) MB, 742.9 / 0.0 ms last resort GC in old space requested
[15184:0x2c46890] 92632 ms: Mark-sweep 1363.6 (1431.6) -> 1363.5 (1431.6) MB, 798.3 / 0.0 ms last resort GC in old space requested
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x378f8390427d]
Security context: 0x2cc5da1206a9 <JSObject>
1: symbolToParameterDeclaration(aka symbolToParameterDeclaration) [/home/mahmood/WebProjects/bisphone-beta-web-lucy/node_modules/typescript/lib/typescript.js:~26179] [pc=0x378f84af538f](this=0x344d038022e1 <undefined>,parameterSymbol=0x1445395f60c1 <SymbolObject map = 0x2b2a3dd2ab11>,context=0x3631eda341b1 <Object map = 0x2b2a3dd51b71>)
2: signatureT...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [ng]
2: 0x88050c [ng]
3: v8::Utils::ReportOOMFailure(char const*, bool) [ng]
4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [ng]
5: v8::internal::Factory::NewLoadHandler(int) [ng]
6: v8::internal::LoadHandler::LoadFromPrototype(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::Smi>, v8::internal::MaybeHandle<v8::internal::Object>, v8::internal::MaybeHandle<v8::internal::Object>) [ng]
7: v8::internal::LoadIC::ComputeHandler(v8::internal::LookupIterator*) [ng]
8: v8::internal::LoadIC::UpdateCaches(v8::internal::LookupIterator*) [ng]
9: v8::internal::LoadIC::Load(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Name>) [ng]
10: v8::internal::Runtime_LoadIC_Miss(int, v8::internal::Object**, v8::internal::Isolate*) [ng]
11: 0x378f8390427d
Aborted (core dumped)
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! bisphone-plus@0.0.0 build: `ng build --aot --prod`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the bisphone-plus@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
我搜索了解决方案,在 failed - JavaScript heap out of memory” and Angular 2 AOT build error - JavaScript heap out of memory 中发现了两个类似的问题。
在这些帖子之后,添加 add --max-old-space-size=9000
属性 但结果发生了变化:
69% building modules 1689/1690 modules 1 active .../@firebase/database/dist/index.cjs.js
#
# Fatal error in , line 0
# API fatal error handler returned after process out of memory
#
#
#
#FailureMessage Object: 0x7f6efe578980Illegal instruction (core dumped)
项目不是很大,前几天搭建成功。没有 --aot --prod
的 ng build
有效。
这对我有用
node --max_old_space_size=5120 ./node_modules/@angular/cli/bin/ng build --prod --build-optimizer
通过将打字稿形式 2.6.x 更新为 2.7.x 问题已解决。